If I have a form that includes some choice with say 5 RadioButtons
(a,b,c,d,e)
then I need an easy way to submit the form with the selected choice
rather than all 5 (N) of them.
I suggest the following additions in next GWT release
A new HiddenInput Widget that has a setName and setValue method and is
added to the form.
ButtonGroup RadioButton.getGroup() //return the ButtonGroup object that
RadioButton lives in.
RadioButton ButtonGroup.getSelected() // get the group's selected
button.
with the above I can then easily determine which of the buttons is
selected, then stuff the value into the HiddenInput and then submit the
form. This reduces the amount of baggage sent to the server and
reduces server-side processing. I realize I could probably do the same
thing with JSNI but its messy and goes outside the framework to
achieve something that a lot of people would want to do with forms.
Sample code usage:
RadioButton aR;
.
.
RadioButton eR;
HiddenInput inp;
FormPanel form;
// don't call setName() on any of the aR-eR. That way they don't get
sent with form.
.
// The hiddenInput will do the work of sending which RadioButton was
chosen.
inp.setName("choice");
// handler for form submit button click
onSubmit () {
RadioButton selectedBut = aR.getGroup().getSelected();
inp.setValue(selectedBut.getName());
form.submit();
}