• 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-multibox How can i make certain values checked

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am using <html:multibox> with LabelValueBean[]. the following is the code

<logic:iterate id="IDRequirement" name="InitialPageDetailViewBean" property="IDRequirements">
<html:multibox property="IDRequirementValues">
<bean:write name="IDRequirement" property="value"/>
</html:multibox>
<bean:write name="IDRequirement" property="label"/>
</logic:iterate>
The above code is rendering me all checkboxes with appropriate values. What i am trying to achieve is to make some of this checkboxes Checked based on a list. I am wondering if there is a straight forward way of doing it by passing my list as part of value in Multibox property.

Can any one suggest, how i can do this. I will really appreciate any help as i am nearing a deadline.....
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vikram,
You just need to set that array of Strings to the IDRequirementValues field of InitalPageDetailViewBean.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am now facing to a case that, when the value of the checkboxes is empty string, all boxes are checked.

But somehow the checkboxes really should not have any values, so, any method that I can have the empty value checkbox, but the checkboxes are NOT checked by default?

Nick
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:

I am now facing to a case that, when the value of the checkboxes is empty string, all boxes are checked.

But somehow the checkboxes really should not have any values, so, any method that I can have the empty value checkbox, but the checkboxes are NOT checked by default?



If you are using DynamicActionForms, and you are using <html:multibox> where having no boxes checked is a valid state, then you must exten org.apache.struts.action.DynamicActionForm and override reset(), setting your String[] to a new String[] of size 0.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about if I am currently using ValidatorForm?

I have put all the *attributes* inside the Form, and for the checkboxes, I used Hashtable to keep track with it.

I have tried that, if I put a *space* in the *value*, even the real value is empty string, the checkboxes behave naturally. My workmates told me that this is the *default* behaviour of Struts.

Any ideas?

Nick
 
vikram nalagampalli
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All. Appreciate your help.

Jeanne, you helped me get my mental block released.....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic