Search code examples
javagwt

How to Synchronize a Form with a CellList


could anyone please explain me this sample for tree item, how it was done in code (in which position), when you choose one contact of the list then it shows on the right side properties of this contact? is it in Example on onInitialize() method?

TREE


Solution

  • First of all the link you provided links to a CellList sample, not a Tree: http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCellList

    Second if you navigate in the SourceCode: Example you can find the following code

     final SingleSelectionModel<ContactInfo> selectionModel = new SingleSelectionModel<ContactInfo>(
            ContactDatabase.ContactInfo.KEY_PROVIDER);
        cellList.setSelectionModel(selectionModel);
        selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
          public void onSelectionChange(SelectionChangeEvent event) {
            contactForm.setContact(selectionModel.getSelectedObject());
          }
        });
    

    This is the selection model attached to the list (aka when you click an item in the list). You can see in the onSelectionChange event that it sets contactForm.setContact(selectionModel.getSelectedObject());

    Now you can navigate to SourceCode: ContactInfoForm where you can search the setContact method in which the values for the labels and text boxes are updated.