You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Whittaker <mi...@ntlworld.com> on 2003/06/10 21:27:54 UTC

iterate checkbox

Could someone please offer me a bit of code to illustrate an iterated
checkbox & multibox
with the appropriate DynaActionForm attribute type and a bit of Action class
code that could set the values?

TIA

And know I can't find it in the archives

--
Mike W


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: iterate checkbox

Posted by James Mitchell <jm...@apache.org>.
On Tuesday 10 June 2003 15:27, Mike Whittaker wrote:
> Could someone please offer me a bit of code to illustrate an iterated
> checkbox & multibox
> with the appropriate DynaActionForm attribute type and a bit of Action
> class code that could set the values?

May not be the best resource, but the taglib tests can be a good place to see 
how different attributes are used:

http://cvs.apache.org/viewcvs.cgi/jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestCheckboxTag2.jsp?rev=HEAD&content-type=text/vnd.viewcvs-markup

...in that jsp, there is a test called 
"testCheckboxPropertybooleanTrueIndexedEnumeration"

It shows an example of how to use the indexed attribute.  You'll notice the 
"EXPECTED_RESULTS" use org.a.s.t.h.BEAN[0].checked and BEAN[1].checked as the 
name of the checkboxes.  

<logic:equal 
    name="runTest" 
   value="testCheckboxPropertybooleanTrueIndexedEnumeration">

 <bean:define id="TEST_RESULTS" toScope="page">
  <logic:iterate id="indivItem" name="lst">
    <html:checkbox property="checked" indexed="true"/>
  </logic:iterate>
 </bean:define>
 <bean:define id="EXPECTED_RESULTS" toScope="page">
  <input type="checkbox" 
         name="org.apache.struts.taglib.html.BEAN[0].checked" value="on"
      checked="checked">

  <input type="checkbox" 
         name="org.apache.struts.taglib.html.BEAN[1].checked" value="on"
      checked="checked">
 </bean:define>
</logic:equal>



....this means that Struts will (if checked by the user, or in this case was 
checked by the test that setup the form) correctly set the checkboxes to true 
(after calling reset on the form) so that you, in your action class, can do 
what you need with the form.


Mulibox is a totally different approach.  You should read the docs and (if it 
helps) review the taglib tests...

http://cvs.apache.org/viewcvs.cgi/jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestMultiboxTag1.jsp?rev=HEAD&content-type=text/vnd.viewcvs-markup

or the exercise-taglib...

http://cvs.apache.org/viewcvs.cgi/jakarta-struts/web/exercise-taglib/html-multibox.jsp?rev=HEAD&content-type=text/vnd.viewcvs-markup

...for detailed examples of usage


>
> TIA
>
> And know I can't find it in the archives

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org