File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes html:mutlibox uncheck ,check problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:mutlibox uncheck ,check problem " Watch "html:mutlibox uncheck ,check problem " New topic
Author

html:mutlibox uncheck ,check problem

Kriti Garg
Ranch Hand

Joined: Sep 13, 2004
Posts: 50
Hi All,

I am iterating through <login:iterate> ag and inside that i am using <html:mutlibox>.

Sppose user sees three checkboxes there can be three scenarios...
1)Click All(Its fine )
2)Unclick All(Its fine,as i am checkinf if its null then all false)
3) Click some and untouched some other

then multibox send array of only those which are checked and i am unable to track which are unchecked.

As browser doesnot recongnise the unchecked checkboxes...
using a hidden field with same name works for single checkbox but not correctly when used inside a iterate with a multibox.

Even in my reset method of ActionForm i am iterating through my array of checkboxes and setting it to false.

How can i solve this problem.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
the <html:multibox> is intended to be used when the property is represented as a string array and you are populating it using checkboxes. In this example:

<html:multibox property="color" value="red" /> <html:multibox property="color" value="blue" />

The ActionForm property color is represented as a string array which could have zero, one, or two elements depending on what is checked. In this scenario, if the resulting array is {"blue"}, you know for sure that the red checkbox was not checked.

If you're using boolean values, you should be using <html:checkbox/>, not <html:multibox>. Example:
<html:checkbox property="hadMeasles" /> <html:checkbox property="hadSmallpox" /> <html:checkbox property="hadMumps" />

If you set all values to false in the reset() method of your ActionForm, when Struts populates the ActionForm ,all boxes checked will have a value of true, and those unchecked will have a value of false. In the above example, if the first checkbox is checked, the form bean's "hadMeasles" property will be true, and all others will be false, provided you have cleared them in your ActionForm's reset() method.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:mutlibox uncheck ,check problem
 
Similar Threads
multibox functionality in struts
struts and multibox
multibox , resultSet, logic:iterate
Multibox reset method ?
Iterator and multibox