There are always multiple ways of accomplishing a task, but I would suggest using 3 boolean properties in a bean. Then that bean gets thrown into a list (probably adds it to the list from the action class associated with the form). Is that helpful at all?
~ Keith -----Original Message----- From: Toni Nehme [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 2:47 PM To: [EMAIL PROTECTED] Subject: RE: html:checkbox tag does not set the checked value Hi Keith, This is an example. User can select multiple at a time. What I am trying to do is to be able to have multiple checkboxes on a page and user could select 2 or 3 and click submit. I want to know which one the user checked. Regards. >From: "Kamholz, Keith (corp-staff) USX" <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> >Subject: RE: html:checkbox tag does not set the checked value >Date: Tue, 25 Jun 2002 14:40:08 -0400 > >Your structure seems kind weird. I'm not sure exactly what you're trying >to >do. Do you need a list of levels, or do you just make the list to hold the >3 options? If you're just holding the 3 options, I would just use a string >as the property, and use radio buttons to select a level. I'm assuming the >user shouldn't be able to select more than 1 level at a time, but maybe >it's >a bad assumption. Could you be more specific about what you want to do? > >Keith Kamholz >Moog >East Aurora, NY >(716) 687-7282 >[EMAIL PROTECTED] > > >-----Original Message----- >From: Toni Nehme [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, June 25, 2002 2:32 PM >To: [EMAIL PROTECTED] >Subject: Re: html:checkbox tag does not set the checked value > > >I have a form, an action and a class: > >I have 3 checkboxes (High,Medium,Low): > >When I check any of those checkboxes and click on submit, >It does not set the value of the selected checkbox to true. > >If anyone knows what is the problem, let me know. > > > >**************************************************** >My Form: > >public class UserChoiceForm extends ActionForm { > > private ArrayList levels = new ArrayList(); > > > public ArrayList getLevels() { > return levels; > } > > public void setLevels(ArrayList _levels) { > levels = _levels; > } > > public Level getLevels(int index) { > return (Level) levels.get(index); > } > > public void setLevels(int index, Level level) { > levels.set(index,level); > } > public UserChoiceForm() { > levels = new ArrayList(); > levels.add(new Level("High")); > levels.add(new Level("Low")); > levels.add(new Level("Medium")); > > > } >} >****************************************************************** >Level.java class: > >public class Level implements java.io.Serializable{ > > private String levelName = ""; > private boolean isChecked = false; > > public Level() { > } > public String getLevelName() { > return levelName; > } > public void setLevelName(String _levelName) { > levelName = _levelName; > } > public boolean getIsChecked() { > return isChecked; > } > public void setIsChecked(boolean _isChecked){ > isChecked = _isChecked; > } > public Level(String name) > { > this.levelName=name; > this.isChecked=false; > } >} >****************************************************************** >My JSP: > > ><html:html> ><head> ><title><bean:message key="userChoices.pageTitle"/> </title> ><html:base/> ></head> ><body> ><html:form action="userChoice"> ><logic:iterate id="levels" name="userChoiceForm" property="levels" > type="ch.thales.model.Level"> > <html:checkbox name="levels" property="isChecked" /> > <bean:write name="levels" property="levelName" /> ></logic:iterate> ><br><br> ><html:submit property="submit" value="Submit"/> ><html:reset/><br> ></html:form> ></body> ></html:html> > > > >****************************************************************** > >From: "Toni Nehme" <[EMAIL PROTECTED]> > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: [EMAIL PROTECTED] > >Subject: html:checkbox tag does not set the checked value > >Date: Tue, 25 Jun 2002 12:23:49 -0400 > > > >Hi, > > > > > >I have a class and an action and a form, > >I am trying to check one of the two checkboxes and submit and > >display the selected checkbox value. > > > > > >The following code is in my form: > > > >public final class TestForm extends ActionForm { > > > > private String chkVal = "on"; > > private boolean isBillable = false; > > > > public String getChkVal() > > { > > return (this.chkVal); > > } > > > > public void setChkVal(String _chkVal) > > { > > this.chkVal = _chkVal; > > } > > > > public boolean getIsBillable() > > { > > return isBillable; > > } > > > > public void setIsBillable(boolean billed) > > { > > isBillable = billed; > > } > > > > public void reset(ActionMapping mapping, HttpServletRequest request) > > { > > isBillable=false; > > } > >} > > > > > >The test.jsp has the following code: > > > ><html:html> > > <head> > > <title> > > <bean:message key="welcome.title"/> > > </title> > > <html:base/> > > </head> > > <body> > > <html:errors/> > > <html:form action="/test"> > > <html:checkbox property="isBillable" value="chkVal"/> > > <html:submit> > > <bean:message key="button.display"/> > > </html:submit> > > </html:form> > > </body> > ></html:html> > > > > > > > >When I click on the button to submit the form, I tried to display the > >attributes of the checkbox and they are still > >isBillable=false > >value="on" > > > > > >Does anybody know how to fix? > >Or anybody knows a detailed html:checkbox with struts detailed example > >to point me to it? > > > > > >Thanks,,, > > > >_________________________________________________________________ > >Get your FREE download of MSN Explorer at >http://explorer.msn.com/intl.asp. > > > > > >-- > >To unsubscribe, e-mail: > ><mailto:[EMAIL PROTECTED]> > >For additional commands, e-mail: > ><mailto:[EMAIL PROTECTED]> > > >_________________________________________________________________ >Join the world's largest e-mail service with MSN Hotmail. >http://www.hotmail.com > > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

