I'm novice in GWT, help pls with my problem.
I try to bind complex data to UI via GWT Editor mechanism. It works
perfectly when binding String fields to TextBox widgets, but I cannot
understand how to bind any field to ListBox widget.
Look at following example, pls


Bean class:

public class MyData implements Serializable {
  String name;
  int gender;
...getters and setters here...

Editor:

public class MyEditor extends Composite implements Editor<MyData> {
  interface Binder extends UiBinder<Widget,MyEditor> {}
  private static Binder binder = GWT.create(Binder.class);
  @UiField TextBox name;
  @UiField ListBox gender;
  public MyEditor()  { initWidget(binder.createAndBindUi(this));  }
}

Editor's *.ui.xml:

Name:<g:TextBox ui:field="name"/></dev>
  <g:ListBox ui:field="gender">
    <g:item value="0">Male</g:item>
    <g:item value="1">Female</g:item>
    <g:item value="2">Shemale</g:item>
  </g:ListBox>

And that's invoking class:

public class MyForm extends Composite {
  interface Driver extends SimpleBeanEditorDriver<MyData,MyEditor> {}
  private Driver driver = GWT.create(Driver.class);
  MyEditor editor;
  ClickHandler handler = new ClickHandler()  {
    public void onClick(ClickEvent event) {
          MyData myData = driver.flush();
          Window.alert("Name=" + myData.getName() + "; Gender=" +
myData.getGender());
        }
  };

  public void drawMe(FlowPanel panel) {
        panel.clear();
        editor = new MyEditor();
        driver.initialize(editor);
        MyData myData = new MyData();
        driver.edit(myData);
        panel.add(editor);
        Button button = new Button("Press Me");
        button.addClickHandler(handler);
        panel.add(button);
  }
}

After entering data and pressing button <Press Me> I see correct value
of String variable "name" in Alert box, but int variable "gender"
always =0, independently of current state of ListBox.

What may be wrong with my code?.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to