Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to maintain checkbox status while switching between pages

 
Savannah Gege
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic