You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Bieberstein <D....@gmx.de> on 2004/01/08 22:53:05 UTC
DynaActionForm and radio-buttons
Hi,
i have a problem with handling my DynaActionsForm (Struts 1.1)and
radio-buttons.
In the JSP is a iteration over a bean (bookingPaymentTickets) that creates
radio-options.
<logic:iterate id="tickets" name="bookingPaymentTickets" scope="request">
Price 1<html:radio property="price" value="1" styleClass="radiobutton"
indexed="true" />
Price 2<html:radio property="price" value="2" styleClass="radiobutton"
indexed="true" />
Price 3<html:radio property="price" value="3" styleClass="radiobutton"
indexed="true" />
<br>
</logic:iterate>
so, for every iteration there are 3 radio-fields.
In my struts-config.xml the form is declared as following:
<form-bean name="bookingPaymentEditForm"
type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
<form-property name="price" type="java.lang.String[]" initial="1" />
</form-bean>
When I look at the HTTP-Monitor after sending the form, i see:
org.apache.struts.taglib.html.BEAN[1].price 1
org.apache.struts.taglib.html.BEAN[0].price 2
No, i want to read the values of the checkboxes in my action:
DynaActionForm form = (DynaActionForm)actionForm;
String price1 = (String) form.get("price",0);
String price2 = (String) form.get("price",1);
...
But that doesn't work :-(
I get the following StackTrace:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.get(Native Method)
at
org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:296)
at
ticketmaker.actions.booking.bookingPaymentEditAction.execute(bookingPaymentE
ditAction.java:40)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:484)
....
Anybody know where the problem is?
Does anybody know a better way to solve the problem of having mutliple lines
of radio-buttons?
Thnx
d.bieberstein
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: DynaActionForm and radio-buttons
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hello Daniel,
let me ask, for the reason of using radio:
you are setting it with: price1 OR price2 OR price3
isn“t it?
so, you get an Array of size 1. (you can click only one)
thats reason for ArrayIndexOutOfBoundsException
perhaps, when you will set multiple values for your price-property
you can do something like this:
<html:select property="price" multiple="true">
<html:option value="1">Price1</html:option>
<html:option value="2">Price2</html:option>
<html:option value="3">Price3</html:option>
</html:select>
then you got an got an array e.g size:2, if
you click 2 items in a browser.
on clicking Pric1 AND Price3
form.get("price",1); gets the value for Price3
i hope i understand you...
greetings
-----Original Message-----
From: Daniel Bieberstein [mailto:D.Bieberstein@gmx.de]
Sent: Thursday, January 08, 2004 10:53 PM
To: Struts Users Mailing List
Subject: DynaActionForm and radio-buttons
Hi,
i have a problem with handling my DynaActionsForm (Struts 1.1)and
radio-buttons.
In the JSP is a iteration over a bean (bookingPaymentTickets) that
creates radio-options.
<logic:iterate id="tickets" name="bookingPaymentTickets"
scope="request">
Price 1<html:radio property="price" value="1"
styleClass="radiobutton" indexed="true" />
Price 2<html:radio property="price" value="2"
styleClass="radiobutton" indexed="true" />
Price 3<html:radio property="price" value="3"
styleClass="radiobutton" indexed="true" />
<br>
</logic:iterate>
so, for every iteration there are 3 radio-fields.
In my struts-config.xml the form is declared as following:
<form-bean name="bookingPaymentEditForm"
type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
<form-property name="price"
type="java.lang.String[]" initial="1" /> </form-bean>
When I look at the HTTP-Monitor after sending the form, i see:
org.apache.struts.taglib.html.BEAN[1].price 1
org.apache.struts.taglib.html.BEAN[0].price 2
No, i want to read the values of the checkboxes in my action:
DynaActionForm form = (DynaActionForm)actionForm;
String price1 = (String) form.get("price",0);
String price2 = (String) form.get("price",1);
...
But that doesn't work :-(
I get the following StackTrace: java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.get(Native Method)
at
org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:296)
at
ticketmaker.actions.booking.bookingPaymentEditAction.execute(bookingPaym
entE
ditAction.java:40)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
oces
sor.java:484)
....
Anybody know where the problem is?
Does anybody know a better way to solve the problem of having mutliple
lines of radio-buttons?
Thnx
d.bieberstein
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org