• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:mutlibox uncheck ,check problem

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic