Tyo
unread,May 26, 2011, 9:11:51 AM5/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
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?.