struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David M. Karr)
Subject Re: How do I use the <html:checkbox> tag to replace of the past JSP code?
Date Thu, 01 Aug 2002 16:12:23 GMT
>>>>> "Struts" == Struts Newsgroup <( <>>

    Struts>     I used the following code to setup checkbox value and checked status
    Struts> before using struts.
    Struts> <%
    Struts>  if (arrSParameters != null) {
    Struts>   for (Enumeration objEnu = arrSParameters.elements() ;
    Struts> objEnu.hasMoreElements() ;) {
    Struts>    objParameter = (PLSystemParameter)objEnu.nextElement();
    Struts> %>
    Struts> <input type="checkbox" name="parameterCode"
    Struts> value="<%=objParameter.getParameterCode()%>"
    Struts> <%=HTMLTools.getCheckedString(arrSPCodes,
    Struts> objSParameter.getParameterCode())%>>
    Struts> <%
    Struts>   }
    Struts>  }
    Struts> %>
    Struts>     I used a for-loop to generate many checkboxes, and all of the
    Struts> checkboxes' values are from java beans' property. Besides, I used a function
    Struts> which utilize whether the specified java bean's property belong to a string
    Struts> array to judge if the "checked" string was showed.

    Struts>     I use the struts now. The following code is my experiment. I didn't know
    Struts> how to setup the checkbox attribut to show "checked" string.
    Struts> <logic:iterate id="objParameter" collection="<%= arrSParameters %>"
    Struts> indexId="index">
    Struts>   <html:checkbox name="objParameter" property="parameterCode" />
    Struts> </logic:iterate>

I believe the better way to do this is to use a "multibox" tag, instead of a
"checkbox" tag.  I almost wonder sometimes whether the need for "multibox" is
larger than "checkbox".  I don't have enough experience building applications
using these to really get a feeling for that.  I would think a very useful
enhancement would be a "NOTE:" in the "checkbox" documentation saying that you
should likely use "multibox" if you are tending for your "value"s to be
attribute or capability names, as opposed to "on" or "yes".

David M. Karr          ; Java/J2EE/XML/Unix/C++

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message