Search code examples
gwtgwt2

Gwt iterate on text controls in a Composite


Can one iterate over all the textbox controls defined in a composite widget? As in I need to extract values of all textboxes to check if they exist - the textboxes should have some data in them.

So I was hoping to have a method like:

for(Widget w: this.getChildren)
 {
      //if widget is a textbox - check value
 }

Composite class does not have a method like getChildren neither a method where I can get elements of a given class - or name and if I get all the elements using NodeList then I need to recursively go until I find a textbox. Is there a more appropriate way to do this?


Solution

  • As the author of the Composite subclass, you can enable this kind of behavior by implementing HasWidgets (or, more specifically, something like getWidgetIterator()).

    There's no way to do this for an arbitrary Composite.