Subject: How do I use the <html:checkbox> tag to replace of the past JSP code?
From: "news.basebeans.com" <[EMAIL PROTECTED]>
 ===
Hi,

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

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

    The result page didn't show the same as the result of the past code. The
struts result is follow code.
<input type="checkbox" name="parameterCode" value="on">
<input type="checkbox" name="parameterCode" value="on">
<input type="checkbox" name="parameterCode" value="on">
<input type="checkbox" name="parameterCode" value="on">
    The checkboxes's value is struts' default value "on" not the java beans'
property. I hope the result page shows the following code.
<input type="checkbox" name="parameterCode" value="WORK_START_HOUR">
<input type="checkbox" name="parameterCode" value="WORK_END_HOUR" checked>
<input type="checkbox" name="parameterCode" value="REST_START_HOUR">
<input type="checkbox" name="parameterCode" value="REST_END_HOUR" checked>
The checkboxes' values are appropriate for the java beans' property and the
"checked" string can be showed or not by condition.

    If the checkbox tag of the struts doesn't support this requirement or I
must extend the checkbox tag of the struts, please tell me, too.

Thank you very much

Judging Huang in Taiwan




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to