aspose file tools*
The moose likes Struts and the fly likes html-multibox How can i make certain values checked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html-multibox How can i make certain values checked" Watch "html-multibox How can i make certain values checked" New topic
Author

html-multibox How can i make certain values checked

vikram nalagampalli
Ranch Hand

Joined: Oct 08, 2001
Posts: 91
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.....
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Vikram,
You just need to set that array of Strings to the IDRequirementValues field of InitalPageDetailViewBean.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
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

Joined: Nov 07, 2003
Posts: 4982
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

Joined: Oct 08, 2001
Posts: 91
Thanks All. Appreciate your help.

Jeanne, you helped me get my mental block released.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html-multibox How can i make certain values checked