wood burning stoves 2.0*
The moose likes Struts and the fly likes Best way to maintain checkbox status while switching between pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Best way to maintain checkbox status while switching between pages" Watch "Best way to maintain checkbox status while switching between pages" New topic
Author

Best way to maintain checkbox status while switching between pages

Savannah Gege
Greenhorn

Joined: May 29, 2014
Posts: 1
I am trying to use a check box to print yes or no on another page. So far when the user clicks on the check box it will print yes on the next page and if it is not checked then it will print no. but when you return to go update the information, the check box is no longer checked even if it is set to yes. how to i maintain the checked status when updating?

I am using struts2 for my checkbox:

first jsp page:



listing the outcome on second jsp page:



i've tried if statements around the checkbox but nothing I am doing is working correctly. can anyone point me in the right direction or give me something to read up on so I can figure this problem out.
Paul Ngom
Ranch Hand

Joined: May 08, 2014
Posts: 307
    
    1

how to i maintain the checked status when updating?


I don't know much about struts2 but what happens is that you need to record the value of the checkbox either in session or table(or hidden field) once in second page so that when you return back to the first page you apply the ?: operator in the value attribute of your checkbox which should be equal to true(checked) or false(not checked) i.e <s:checkbox ... value="(condition)?true:false"/> where condition is a test on the previously saved value of the checkbox.

I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to maintain checkbox status while switching between pages