Matt, Thanks for the response. Are you saying that the getter and setter methods will be called with an index value? So the setter signature in my example would be: void setVerified(int index, String value) and the setter would be void getVerified(int index) ?
Also, how do I know the list size to deal with and therefore know how to size the string array? Thanks, I appreciate your help. Kelly > [Original Message] > From: Matt Raible <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Date: 3/28/2003 7:30:37 PM > Subject: RE: [displaytag-user] Issues with a checkbox decorator (help) > > I'd try making your form bean have a String[] for the getter/setter of > the checkbox's value and then name all the checkboxes with the same > name. > > HTH, > > Matt > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On > > Behalf Of Kelly Clauson > > Sent: Friday, March 28, 2003 4:42 PM > > To: [EMAIL PROTECTED] > > Subject: [displaytag-user] Issues with a checkbox decorator (help) > > > > > > I am attempting to use a Decorator to put a checkbox in one > > column of a table. I am running into a couple of issues, but > > I don't know if my approach is correct. > > > > My decorator code looks like this: > > > > public class CheckboxDecorator extends Decorator { > > public CheckboxDecorator() { super(); } > > public String getNullValue() { return null; } > > > > public String getCheckbox() { > > MyBean bean = (MyBean) getObject(); > > StringBuffer s = new StringBuffer(); > > s.append("<input type=checkbox name=\"verified\" value=\"on:"); > > s.append(getListIndex()); > > s.append("\""); > > boolean checked = bean.getVerified(); > > if (checked) { > > s.append(" checked=\"true\""); > > } > > s.append("/>"); > > return s.toString(); > > } > > } > > > > Basically, I'm just returning an html formatted string that > > contains a checkbox. > > > > My (simplified) jsp: > > > > <%@ taglib uri="/WEB-INF/display.tld" prefix="display" %> > > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> > > <html:form action="/List" name="ListForm" > > type="path.to.ListForm"> <display:table > > width="80%" > > name="elements" > > scope="session" > > border="1" > > cellpadding="5" > > pagesize="8" > > export="true" > > requestURI="list.do" > > decorator="path.to.CheckboxDecorator"> > > > > <display:column align="center" property="checkbox" title="Verify"/> > > <display:column align="center" property="ID"/> > > ... > > </display:table> > > <html:submit/> > > </html:form> > > > > And the relevant portion of the form bean: > > > > public void setVerified(String aVerified) { > > StringTokenizer s = new StringTokenizer(aVerified, ":"); > > String onoff = s.nextToken(); > > int index = Integer.parseInt(s.nextToken()); > > MyBean bean = (MyBean) mElements.get(index); > > if (onoff.equals("on")) { > > bean.setPublished(true); > > } > > else { > > bean.setPublished(false); > > } > > } > > > > > > The checkbox column is displaying properly. The main problem > > I'm having is that when I hit the submit button, I expect the > > setVerified method on the form bean to be called for each box > > that is checked. This does not happen. The method is only > > called for the first occurrence of a checked box. Why???? > > > > Another issue is with the Decorator.getListIndex method. I > > thought this method would return the current object's index > > in the complete list, but it returns the index on the current > > page. Just as the getViewIndex method does. Is this a bug or > > a configuration issue? > > > > Am I completely on the wrong track in trying to get a > > checkbox in a column? Has anyone successfully implemented > > this? I would really appreciate some help. I've been staring > > at this for quite a while now. > > > > Thanks, > > > > Kelly Clauson > > [EMAIL PROTECTED] > > > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: > > The Definitive IT and Networking Event. Be There! > > NetWorld+Interop Las Vegas 2003 -- Register today! > > http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en > > _______________________________________________ > > displaytag-user mailing list [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/displaytag-user > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: > The Definitive IT and Networking Event. Be There! > NetWorld+Interop Las Vegas 2003 -- Register today! > http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en > _______________________________________________ > displaytag-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/displaytag-user ------------------------------------------------------- This SF.net email is sponsored by: The Definitive IT and Networking Event. Be There! NetWorld+Interop Las Vegas 2003 -- Register today! http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en _______________________________________________ displaytag-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/displaytag-user

