You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "David M. Karr" <dm...@earthlink.net> on 2002/08/01 18:12:23 UTC
Re: How do I use the tag to replace of the past JSP code?
>>>>> "Struts" == Struts Newsgroup <(@Basebeans.com) <st...@basebeans.com>> writes:
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++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>