Grandiosa
30 May 2008, 5:21 AM
Given example program below:
1. Pressing first radio prints following to GWT shell log output:
[INFO] radio1 change, value: true
[INFO] radio2 change, value: false
But actually, radio2 didn't change, it was OFF at startup and is till OFF
If I now move the mouse out of app window and click in GWT shell window
another event is detected on the selected radio, probably because of lost focus or something:
[INFO] radio1 change, value: true
2. Now, pressing second radio prints following:
[INFO] radio1 change, value: false
[INFO] radio2 change, value: true
This is ok, as both radios now changed. But again, if I move focus from
app window and click in the GWT shell window this is printed:
[INFO] radio2 change, value: true
I am firing events from my View when my Radio changes to ON, so for now I must check if the Radio is already true to filter out any redundant Change events.
public class Main implements EntryPoint {
public void onModuleLoad() {
Viewport vp = new Viewport();
vp.setLayout(new FitLayout());
ContentPanel panel = new ContentPanel(new CenterLayout());
FormPanel form = new FormPanel();
form.setFieldWidth(210);
form.setWidth(380);
Radio radio1 = new Radio();
radio1.setName("radio1");
radio1.setFieldLabel("First");
radio1.setValue(true);
radio1.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
GWT.log("radio1 change, value: " + be.value, null);
}
});
Radio radio2 = new Radio();
radio2.setName("radio2");
radio2.setFieldLabel("Second");
radio2.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
GWT.log("radio2 change, value: " + be.value, null);
}
});
RadioGroup radioGroup = new RadioGroup("Whatever");
radioGroup.setFieldLabel("Order");
radioGroup.add(radio1);
radioGroup.add(radio2);
form.add(radioGroup);
panel.add(form);
vp.add(panel);
vp.layout();
RootPanel.get().add(vp);
}
}
1. Pressing first radio prints following to GWT shell log output:
[INFO] radio1 change, value: true
[INFO] radio2 change, value: false
But actually, radio2 didn't change, it was OFF at startup and is till OFF
If I now move the mouse out of app window and click in GWT shell window
another event is detected on the selected radio, probably because of lost focus or something:
[INFO] radio1 change, value: true
2. Now, pressing second radio prints following:
[INFO] radio1 change, value: false
[INFO] radio2 change, value: true
This is ok, as both radios now changed. But again, if I move focus from
app window and click in the GWT shell window this is printed:
[INFO] radio2 change, value: true
I am firing events from my View when my Radio changes to ON, so for now I must check if the Radio is already true to filter out any redundant Change events.
public class Main implements EntryPoint {
public void onModuleLoad() {
Viewport vp = new Viewport();
vp.setLayout(new FitLayout());
ContentPanel panel = new ContentPanel(new CenterLayout());
FormPanel form = new FormPanel();
form.setFieldWidth(210);
form.setWidth(380);
Radio radio1 = new Radio();
radio1.setName("radio1");
radio1.setFieldLabel("First");
radio1.setValue(true);
radio1.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
GWT.log("radio1 change, value: " + be.value, null);
}
});
Radio radio2 = new Radio();
radio2.setName("radio2");
radio2.setFieldLabel("Second");
radio2.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
GWT.log("radio2 change, value: " + be.value, null);
}
});
RadioGroup radioGroup = new RadioGroup("Whatever");
radioGroup.setFieldLabel("Order");
radioGroup.add(radio1);
radioGroup.add(radio2);
form.add(radioGroup);
panel.add(form);
vp.add(panel);
vp.layout();
RootPanel.get().add(vp);
}
}