开发者

Clone a panel of widgets

开发者 https://www.devze.com 2023-01-19 15:59 出处:网络
is it possible in GWT to clone a panel?If so, are all the handler settings copied as well? Basically I have a Panel full of controls, all laid out, I want to copy it and pop it up in a PopupPanel wit

is it possible in GWT to clone a panel? If so, are all the handler settings copied as well?

Basically I have a Panel full of controls, all laid out, I want to copy it and pop it up in a PopupPanel without having to go through the code that created the controls in the first place.

开发者_StackOverflow中文版

I got as far as DOM.clone(), and this message post. But there is no wrap() in Widget, UIObject etc. setElement() is protected.


Quick way to build a Widget from a DOM element:

Widget widget = new Widget () {{
    setElement(myElement);
}};

But no, AFAIK DOM.clone() isn't going to copy attached handlers as well. I suspect this won't work as well as you're hoping.


Have you considered creating a new GWT widget, consisting of all of those controls? That way you can host the widget panel in both places without resorting to cloning it. (And possibly saving you subtle bugs in the process.)


Create a new class with all the controls and other features that you have in your panel and treat this as a new widget... Now you don't have to worry about cloning them, you can use this as a regular widget in your program (you can initialize it the same way you do rest of the widgets)... This is how i started off for one of my projects, where i was trying to clone a panel...

0

精彩评论

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