thanx.

I have to set the value of the checkbox in the JSP.
for this I write 

<html:checkbox property='"primKey" value="val"/>
problem is that the value is dynamic, so I have to use something like value=<%=val%>
but this is scripting ...  :-(
use of bean:write fails to render the checkbox.

Do I have any other option.



-----Original Message-----
From: Carl Walker [mailto:[EMAIL PROTECTED]
Sent: Friday, May 30, 2003 4:42 PM
To: Struts Users Mailing List
Subject: Re: Checkbox


You should use a java.lang.String or java.lang.String[] property if you want
to have 'abc' submitted when checkbox 'chk' is checked.

If you want 'true' to be sent when 'chk' is checked, then change 'abc' to
'true'.

Take a look at this example for additional guidance

<%-- FILE checkForm.jsp --%>
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>

<html:html>
<body>
<h1>checkForm</h1>
<html:form action="/check.do">

<p>Do you like soda?</p>
<html:checkbox property="likesSoda" value="true">Yes</html:checkbox><br>

<p>If you like soda (or were forced to drink one) what would you drink?</p>

<html:checkbox property="sodas" value="coke">Coke</html:checkbox><br>
<html:checkbox property="sodas" value="pepsi">Pepsi</html:checkbox><br>
<html:checkbox property="sodas" value="7-up">7-up</html:checkbox><br>
<html:submit value="Submit" />

</html:form>
</body>
</html:html>
<%-- END FILE checkForm.jsp --%>

<%-- FILE check.jsp --%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="logic" uri="/WEB-INF/struts-logic.tld" %>
<%@ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>

<html>
<body>
<h1>check</h1>

<bean:define id="likesSoda" name="SodaForm" property="likesSoda" />
<p>Likes soda?: <bean:write name="likesSoda" /></p>

<p>Preferred sodas:</p>
<bean:define id="sodas" name="SodaForm" property="sodas" />
<logic:iterate id="soda" name="sodas">
  <bean:write name="soda" /><br>
</logic:iterate>
</ul>
</body>
</html>
<%-- END FILE check.jsp --%>

Put these in your struts-config.xml  (in the appropriate sections).
    <form-bean name="SodaForm"
               type="org.apache.struts.action.DynaActionForm">
      <form-property name="likesSoda" type="java.lang.Boolean"
initial="false"/>
      <form-property name="sodas" type="java.lang.String[]" />
    </form-bean>

    <action path="/checkForm" forward="/checkForm.jsp" />

    <action path="/check"
            name="SodaForm"
            scope="request"
            forward="/check.jsp" />



FILE
"Abhinav (Cognizant)" wrote:

> This one is not getting into my head ..
>         <html:checkbox property="chk" value="abc" />
> and in the form bean
>         boolean getChk(), void setChk(boolean)
> checkbox is checked and form is submitted.
> how do I retreieve the value "abc"
>
> Thanx.
>
>   ------------------------------------------------------------------------
>                               Name: InterScan_SafeStamp.txt
>    InterScan_SafeStamp.txt    Type: Plain Text (text/plain)
>                           Encoding: 7bit
>
>                                Name: InterScan_Disclaimer.txt
>    InterScan_Disclaimer.txt    Type: Plain Text (text/plain)
>                            Encoding: 7bit
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

****** Message from InterScan E-Mail VirusWall NT ******

** No virus found in attached file noname.htm

No Virus detected in the attached file(s).
*****************     End of message     ***************


This e-mail and any files transmitted with it are for the sole use of the intended 
recipient(s) and may contain confidential and privileged information. If you are not 
the 
intended recipient, please contact the sender by reply e-mail and destroy all copies 
of 
the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or 
copying 
of this email or any action taken in reliance on this e-mail is strictly prohibited 
and 
may be unlawful.

          Visit us at http://www.cognizant.com

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

Reply via email to