开发者

how do i clone a widget in GWT , any widget not just button?

开发者 https://www.devze.com 2023-02-11 15:11 出处:网络
i saw it on here GWT Clone a widget using DOM.clone but then it had the method Button.wrap , but i dont wanna clone the button

i saw it on here GWT Clone a widget using DOM.clone but then it had the method Button.wrap , but i dont wanna clone the button i wanna clone the child elements of horizontalPanel.

im using this to clo开发者_运维知识库ne the widget but its removing all those handlers and stuff from the cloned widget as its using setElement method , which is just copying the HTML stuff to new HTML ,

class ClonedWidget extends Widget {
    public ClonedWidget(Element element) {
        setElement(element);
    }
}

any other way ?


AFAIK there's no built-in way to clone arbitrary widget. One way to solve this problem is just to create new widget (in this case some factory method can be helpful).

Also, you can take a look at this question.


Is there a particular reason you need to clone the widget?

Creating a new instance is often the way to go.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号