Radio Button Group

1,118 views
Skip to first unread message

Sam

unread,
Mar 31, 2008, 12:26:09 PM3/31/08
to Google Web Toolkit
I have a simple web page with a from. It has a Radio Button Group and
2 radio buttons in it. But on form submit, the server side gets a
value of ON for the group name rather than the value of the radio
button selected in the group. Anyone seen this behaviour ? Any ideas
how to get the values sent to the server ?

Sam

Carl Scott

unread,
Mar 31, 2008, 1:50:10 PM3/31/08
to Google Web Toolkit
Does your code look like this:

RadioButton defaultOption = new RadioButton("mygroup", "Default
Option");
RadioButton rb1 = new RadioButton("mygroup", "Option 1");
RadioButton rb2 = new RadioButton("mygroup", "Option 2");
RadioButton rb3 = new RadioButton("mygroup", "Option 3");
defaultOption.setChecked(true);

??

Sam

unread,
Mar 31, 2008, 2:11:45 PM3/31/08
to Google Web Toolkit
Yes, heres how my code looks:

RadioButton upload = new RadioButton("LOAD_OPTION", "UPLOAD", true);
RadioButton update = new RadioButton("LOAD_OPTION", "UPDATE", true);
upload.setChecked(true);

On the server side (servlet), I print request values and all I get is
"ON" for "LOAD_OPTION" parameter. I expect to see either "UPLOAD" or
"UPDATE".

What am I missing here ?

Sam

unread,
Mar 31, 2008, 2:43:36 PM3/31/08
to Google Web Toolkit
Yes, and on the server side I expect to see either "Option 1" or
"option 2" to be sent as the value for the parameter "mygroups". But
all I get is "ON". Why is that ?


On Mar 31, 12:50 pm, Carl Scott <carl.sc...@solertium.com> wrote:
> > Sam- Hide quoted text -
>
> - Show quoted text -

Carl Scott

unread,
Mar 31, 2008, 5:17:24 PM3/31/08
to Google Web Toolkit
Hmm, odd. I don't often use true Forms in GWT and when I do I don't
usually use Radio Buttons. I would offer a ListBox as a temporary
workaround but the current behavior is odd. The "ON" state is a
default value returned when you declare a radio button without giving
it an explicit value.

If I think of something I'm overlooking I'll repost.

Carl Scott

unread,
Mar 31, 2008, 5:19:16 PM3/31/08
to Google Web Toolkit

ognist...@gmail.com

unread,
May 7, 2014, 8:03:17 AM5/7/14
to google-we...@googlegroups.com, Google Web Toolkit, vrpa...@gmail.com
May be I will be usefull for somone, it shoudl be done like this:

 RadioButton reportTypeRadioButton1 = new RadioButton("report_type", "label");
        reportTypeRadioButton1.setValue(true);  // default checked - its not obligatory
        reportTypeRadioButton1.setFormValue("XLS");

 RadioButton reportTypeRadioButton2 = new RadioButton("report_type", " label 1");
        reportTypeRadioButton2.setFormValue("CSV"); 
Reply all
Reply to author
Forward
0 new messages