Re: values from request question
Re: values from request question
- Subject: Re: values from request question
- From: "Daniele Corti" <email@hidden>
- Date: Fri, 21 Sep 2007 10:09:27 +0200
2007/9/20, Johann Werner <email@hidden>:
Am 20.09.2007 um 17:37 schrieb Daniele Corti:
2007/9/20, Johann Werner <
email@hidden>:
Hi all,
I have a weird behaviour of takeValuesFromRequest. I have a page with
a form that has a radio button group having values from 1 to n.
<woform>
<worepetition>
<radiobutton>
</worepetition>
</woform>
with
radiobutton : WORadioButton {
name = "reportSelect";
value = counter;
selection = selectedReport;
}
gives
<form name="form_0_0_3_25_5" method="post" action=""
<input type="radio" value="1" name="reportSelect">
<input type="radio" value="2" name="reportSelect">
<input type="radio" value="3" name="reportSelect">
...
<input type="submit" name="0.0.3.25.5.7.0">
</form>
selectedReport is an int variable that is set to 0 in
appendToResponse. When I select one of the radiobuttons and submit
the form I get the appropriate value in selectedReport for all radio
buttons except for the first one. That is if I select the first one
the value of selectedReport in my form action is 0 and not 1 as I
would expect.
I added takeValuesFromRequest to my component and by checking the
form values in WORequest I can see that the value 1 is there but I
don't know why just that value is not assigned to the variable. The
only way I found to make this work is to add
if (aRequest.formValueForKey("reportSelect") != null) {
selectedReport = new Integer((String)aRequest.formValueForKey
("reportSelect")).intValue();
}
to takeValuesFromRequest to manually assign the value. But it should
not be necessary to do so! So does anyone have an idea what is going
wrong or did someone else observe that behaviour?
I could make a mistack but I think radio button take only String value, try use selectedReport as String
changed it to String and when I select the first radio button no value gets into the variable as before and by selecting one of the other buttons I get:
<com.webobjects.appserver._private.WOComponentRequestHandler>: Exception occurred while handling request:
java.lang.IllegalArgumentException: While trying to set the field "selectedReport" on an object of type
com.oyosys.source.administration.AdminNewVersion we expected a java.lang.String but received a java.lang.Integer with a value of 2. This often happens if you forget to use a formatter.
So I could use a formatter to prevent this error but this doesn't change the fact that for selecting button No. 1 no assignement seems to be made in takeValuesFromRequest for whatever reason. :-(
Ok try to use WORadioButtonList, instead of WORepetition, and use a list of Strings: new String[]{"1", "2", "3", ..}
<wo:WOForm>
<wo:WORadioButtonList list="$myListOfStrings" selection="$
selectedReport" />
<wo:WOSubmitButton action="" />
</wo:WOForm>
jw
jw
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (
--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden
--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS
--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young
--
Daniele Corti
AIM: S0CR4TE5
Messenger:
email@hidden
--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS
--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden