The solution I am using assumes you are using an ActionForm.  Look here:

http://jakarta.apache.org/struts/userGuide/building_controller.html#map_action_form_classes

If you change your ActionForm to support a map-backed ActionForm then
Struts will call your setValue() method with only the names of the
checkboxes that were checked.

So in your ActionForm you have two methods:

   public void setValue(final String key, final Object value);
   public Object getValue(final String key);

Then in your JSP page you do the following:

<display:table name="sessionScope.list" id="thing" requestURI="...">
   <display:column title="" sortable="false" >
      <input type="checkbox" 
        name="value(<bean:write name="thing" property="id" />)"
        value="x"
        />
   </display:column>
   ...
</display:table>

where each object in the list identified by the session scope parameter
"list" has a method called getId() which returns some unique identifier. 
Your business object needs to generate a unique identifier for the next
step.

Then when the user submits the form, Struts will call the setValue()
method on your form and will pass in the value of getId() and the value
"x" *** for each clicked checkbox ***.  In your setValue just keep track
of which unique IDs you see.

Hope this helps.


--Marty

--- Carolina Dolan <[EMAIL PROTECTED]> wrote:
> I need to use checkboxes with displayTag & struts, but I haven't been
> able to find a solution. Can you give me a hand?
> 
> Carolina
> 
> -----Mensaje original-----
> De: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] nombre de Martin
> Wegner
> Enviado el: Wednesday, May 12, 2004 5:10 PM
> Para: [EMAIL PROTECTED]
> Asunto: RE: [displaytag-user] Displaytag and a Form
> 
> 
> > But Check boxes are nasty. If they are not checked then nothing gets
> > return so you have to cycle through all the parameters and determine
> > which ones are checked and which ones are not checked. 
> 
> I also wanted to add that Struts has an elegant solution for this. 
> Struts
> will inform you exactly which checkbox have been checked.  No cycling
> through all of the possibilities.  Struts is a great framework and works
> great with Displaytag.
> 
> 
> --Marty
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user



-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to