This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Hi, I am using struts for my web application. I have a form bean which contains field for Shipping & Billing address details. Now I have a JSP page with <html:form> for entering values into this form bean. Now This page has two sections (billibg & Shipping address) into same form. Now between these two sections I want to add a checkbox with title "Check if shipping address is same as billing." So that when user clicks on checkbox all the fields in the shipping address field gets disabled & when user submitts form, then inside my action class (say Addaddressaction.java) it should check the value of checkbox & decide whether to enter same values into database for both billing & shipping section. How to render checkbox into JSP page. (I dont want to include any special parameter into my formbean's definition for checkbox.) & also how to retrieve value of this checkbox into action class?
If you want to retrieve the value of the checkbox in your action class, you should define a value for it in the form bean. Also, in your form bean's reset method you should set the value to false, because I believe that unchecked checkboxes come back as null or zero length. If you are using a DynaValidatorForm you can set initial="false" and I believe it will work.
Hi, thanx for your reply. I iagree with your reply but in my question I already mentioned that :- "I dont want to include any special parameter into my formbean's definition for checkbox". I just want to define checkbox into my jsp page inside html:form & also it should be accessed inside action class.
Joined: May 05, 2006
Originally posted by Prashant Tiwari: "I dont want to include any special parameter into my formbean's definition for checkbox". I just want to define checkbox into my jsp page inside html:form & also it should be accessed inside action class.
I don't know how to do that. Why can't you add another parameter to your formbean? This is the exact purpose of a form bean.