drag and drop - How to get the component out of the DragAndDropWrapper again -


i following this guide in order achieve solution drag , drop scenario. i've component (slider) wrapped in "draganddropwrapper". works pretty well.

                final slider slider = new slider(title);                 slider.setvalue(1.0);                 slider.setwidth("100%");                 slider.setmax(4);                 slider.addstylename("ticks");                  final draganddropwrapper sliderwrap = new draganddropwrapper(slider);                 sliderwrap.setdragstartmode(dragstartmode.component);                 sliderwrap.setsizeundefined();                 ((abstractorderedlayout) this.getcontent()).addcomponent(sliderwrap); 

okay, simplify things let's assume have button wrapped in such draganddropwrapper.

final button button = new button("an absolute button");  final draganddropwrapper buttonwrap = new draganddropwrapper(button); buttonwrap.setdragstartmode(dragstartmode.component); 

how supposed button out of there again? i'm searching this:

button mybutton = buttonwrap.getcomponent(0); 

the api doesn't state method can used (afaik).

use getcompositionroot method . unfortunately, method protected need extend draganddropwrapper , change method visibility. example:

public class mydraganddropwrapper extends draganddropwrapper {     public mydraganddropwrapper(grid grid)     {         super(grid);     }      @override     public component getcompositionroot(){         return super.getcompositionroot();     } } //...later on grid grid = new grid(container); grid.setid("fancyid"); mydraganddropwrapper w  = new mydraganddropwrapper(grid); system.out.println(w.getcompositionroot().getid()); layout.addcomponent(w); 

remember can declare variable w in above code original draganddropwrapper , access getcompositionroot via casting.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -