This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I am new to Struts programming. My requirement is to Display a check box in a Page1(with standard display text) and display some additional information in Page2 if the check box is checked.(should be developed using struts)
i created a Actionform with a boolean variable
In my JSP page1 i am using <html:checkbox> to generate a check box
In my struts-config.xml the scope of this action is set to "Session" (this should be session for some other purpose)
If i check the checkbox for the first time and clicking on the Next button. Page2 gets displayed with the additional text.
On clicking the Back button on page2, it displays page1 with values retained(check box is selected since scope is set as session). On deselecting the checkbox and clicking on the next button, Page2 gets displayed with the additional text. The "displayAddText" does not get toggled when the check box toggles. (whereas the value toggled for the first time).
what could be the problem? where am i going wrong? please let me know.
This is necessary because of a quirky behavior of HTML. When a checkbox is not checked, no value is returned to the server. That means if the boolean is set to true, it will stay set to true even if the box is unchecked. Since Struts automatically calls the reset method before populating the properties of the ActionForm, the above code makes sure the value starts out as false and only gets set to true if the box is checked. [ September 13, 2006: Message edited by: Merrill Higginson ]