You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mattos, John" <jm...@Indemand.com> on 2002/03/22 18:47:52 UTC

RE [2]: Form Question - Dynamic number of checkboxes - Multibox ?

Okay, so now I have the following:

    <logic:iterate id="sb"
	type="com.indemand.indab.application.invoice.SuspendsTransaction"
	collection="<%=suspendsByProd%>">
      <TR>
        <TD>
		<%=sb.getProductName()%>&nbsp;
	 </TD>
	 <TD>
		<html:multibox property="assetId"
value="<%=sb.getCheckBoxName()%>"/>

	 </TD>
      </TR> 
    </logic:iterate>

and I have an int[] field on my bean called "assetId"

and it's telling me 

"You must specify the value attribute or nested tag content"

I thought that's what I was doing when I specified
value="<%=sb.getCheckBoxName()%>" in the multiBox.

the getcheckboxName, by the way, returns the assetId, so I hope to end
upwith an array of these things in the bean

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014

-----Original Message-----
From: Gaulin.David@ic.gc.ca [mailto:Gaulin.David@ic.gc.ca]
Sent: Friday, March 22, 2002 11:42 AM
To: struts-user@jakarta.apache.org
Subject: RE: Form Question - Dynamic number of checkboxes


Look at the multibox tag.  Add an attribute to your form called product (I
think it has to be an a String array) and when you read.  It will populate
the array with the product selected.

David



-----Original Message-----
From: dhay@lexmark.com [mailto:dhay@lexmark.com]
Sent: Friday, March 22, 2002 11:32 AM
To: Struts Users Mailing List
Subject: Re: Form Question - Dynamic number of checkboxes




why don't you use indexed=true on the checkboxes and it will create indexed
names for them.  Have to use nightly build or new 1.1 beta.

Cheers,
Dave




"Mattos, John" <jm...@interlock.lexmark.com> on 03/22/2002
11:13:16 AM

Please respond to "Struts Users Mailing List"
      <st...@interlock.lexmark.com>

To:   "'struts-user@jakarta.apache.org'"
      <st...@interlock.lexmark.com>
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  Form Question - Dynamic number of checkboxes



Hi there all

I'm generating a form that can have dynamic checkboxes depending on
information retrieved from my database. I basically retrieve a bunch or rows
and for each one, I want to create a checkbox.

Than, in the Action class handling the form submission, I plan to loop
through the checkboxes, and build an array of those that were selected, and
do something to them.

The problem is that I am tying to name the checkboxes for the ID of the
row... here is a JSP snippet:

    <logic:iterate id="sb"
     type="com.indemand.indab.application.invoice.SuspendsTransaction"
     collection="<%=collectionName%>">
      <TR>
        <TD><%=sb.getProductName()%>&nbsp;</TD>
      <TD><html:checkbox property="<%=sb.getCheckBoxName()%>" /></TD>
      </TR>
    </logic:iterate>

<!-- end of snippet -->

the getCheckBoxName() comes from the database, and it correcponds to the
"Product" in this row, and it's dynamic.

Struts complains with the following error message....

     No getter method for property 4363 of bean
org.apache.struts.taglib.html.BEAN

Essentially, I'm trying to create the following
<input type="checkbox" name="4363"> and struts can't find get4363() in the
bean. No surprise there, I can't create getters for all the possibilities. I
just planned to loop through the submitted form fields to get the ids
checked.

Is there any way that Struts can not care that the setters don't exist?

Does this make sense?


John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>








--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>