aspose file tools*
The moose likes Struts and the fly likes how to use html:checkbox and requestgetParameterValues() in association Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to use html:checkbox and requestgetParameterValues() in association " Watch "how to use html:checkbox and requestgetParameterValues() in association " New topic
Author

how to use html:checkbox and requestgetParameterValues() in association

samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
Hi all,
I am tring to access the vlaues that are associated with the checkboxes which are dynamically generatd. The code in the JSP is as follows

<logic:iterate id="array" name="DATA">

<tr>
<bean:write name="array" property="docNumber" /></td>
<bean:write name="array" property="docclassid" /></td>
<bean:write name="array" property="docid" /></td>
<html:checkbox name="documentVerificationForm"
property="checkBox" value=" ??? ">
</html:checkbox>
</td>
</tr>
</logic:iterate>
wheere "documentVerificationForm" is the name of the form "DocumentVerificationForm" in struts config
DATA is an ArrayList and is stoired in request scope and in this arraylist I am stoiring multiple instance of the form bean(documentVerificationForm). Now I want to link the value of the variable docNumber with the text box and access all those docNumber in action class using the code
String docIds [] = request.getParameterValues(???)
so can anybody plzzzz tell me what should be the valus at "?"

Thanks in advance
Samir



Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
<logic:iterate name="ApartmentFormBean" id="facility" property="facilityList">
<html:multibox property="selectedFacilities">
<bean:write name="facility" property="id"/>
</html:multibox>
<bean:write name="facility" property="name"/>
</logic:iterate>
I have implemented a similar feature in my application.
Script above displays the list of checkboxes and values selected.
FacilityList is my predefined facility list and selectedFacilities is a string array which contains ids of previously selected facilities.

There could be better way of doing it,I am just a starter in Struts.


SCJP5
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
You can retrive in request as follows:
String facilityListing [] = request.getParameterValues("selectedFacilities");
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
I'm not sure if this is what you're getting at but you must assign a value of whatever you want it to hold if it's checked. If you would like the box to display a 1 when it is checked then 'value = 1'. When the box is not checked it will return a value of 'null'. You must then handle for the null value if if it is going to be stored.

For example, if you are trying to take the value of the checkbox and store it as a boolean then the value = "true". Then you would have to handle



I'm not sure if that's what you were getting at but I hope I could be of some help to you.
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
selectedFacilities is a string array

But the specification says the property element of the <html:multibox> should be a type of java.util.Map....
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
But the specification says the property element of the <html:multibox> should be a type of java.util.Map....

I don't know where you got that idea, but it's incorrect. The property for an <html:multibox> should be a String array.Here is the link to the section of the User guide that describes this tag. Here's a quote from it:

Renders an HTML <input> element of type checkbox, whose "checked" status is initialized based on whether the specified value matches one of the elements of the underlying property's array of current values.


Merrill
Consultant, Sima Solutions
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
You are rt Merrill ....I was refering to some local author's book from which I got that information.....And yeah..the way shilpa told me to do the stuff works out....
thanks shilpa for your precious help
thanks to Merrill too for clarification ....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to use html:checkbox and requestgetParameterValues() in association