> Is there some clever way to achieve the same thing in 1.0? I can properly
initialized my fields using the
> 'iterate' tag, but I want the parameter names to come back as "field01,
field02, ..." or some-such.

All

I figured out a solution myself... though it may not conform with the
preferred Struts patterns.  Here's how I did it, for the archives:

In short, I render the HTML Input tag 'by hand' rather than using Struts
<html:checkbox> tag.  Then I add code in the action class 'submit' case
to put the parameter values in the form.

Here's the JSP:

<logic:iterate name="myForm" id="myListItem" indexId="myIdx"
property="myList" >

    ... other HTML, probably table rows & such ...

    <INPUT
       <logic:equal name="myListItem" property="enabled" value="true">
       checked
       </logic:equal>

       name=checkedListItems type=checkbox value=<bean:write name="myIdx"/>>

    ... other HTML  ...

</logic:iterate>

Notes:

    * This accesses the collection, myform.mylist.

    * The objects in that collection must have a "boolean getEnabled(int
      idx)" method.

    * Notice that I'm rendering the same parameter name
      "checkedListItems" for each checkbox, but the value is set to the
      collection index.  If the 3rd and 5th items are checked, I'll get
      a request parameter like so:

        "checkedListItems" = { "2", "4" }

    * Alternately you could leave the value set to "true" or "1" and
      construct a fancy parameter name.  Then you'd get this in the
      request.

        "checkedListItem[2]" = { "true" } "checkedListItem[4]" = {
        "true" }

      This approach seems more like the documented "indexed" attribute.


-Have fun
-Matt.


Reply via email to