Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

How do I maintain the state of checkboxes across page?  RSS feed

 
moo moo farm gal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all,
I am currently using the JspTag Library to do the paging of a large set of data. Each row of data comes with a checkbox. I want to enable the user to check the boxes they want, and go on to other pages to check other boxes. As they go through all pages, all the boxes should remained checked. How do I do this? Someone kindly help.. any suggestions will be greatly appreciated!
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Report post to moderator
Store the value/state of your checkboxes in a bean and access them via the session object. That's what session management is for...managing/maintaining state accross multiple pages.
 
moo moo farm gal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi, thanks for the reply. But.. how can I go about doing this? I'm really really lost. I know how to use session to store information to pass to other pages, but I can't seem to do the same for this.
Basically, I have 2 files to handle. One file (displayPages.jsp) does the displaying and paging of all the data. Each data row has a checkbox with unique name, so that I can identify which is checked or not.
Let's say I have 40 rows of data. I can display 20 rows of data on each page. Which means there will be 2 pages. The user goes from page to page by clicking on a link. So, first 20 rows will displayed on displayPages.jsp?offset=0 and next 20 rows on displayPages.jsp?offset=20.

I like to know:
  • How do I save the values of all the checkboxes on a page?
  • How do I retrieve the values of the checkboxes when this page is requested again?

  • Can I have some sample code to work from? I have tried out many ways and yet still bugged by this problem for almost a week!
    Any reply will be greatly appreciated!
     
    David O'Meara
    Rancher
    Posts: 13459
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
    • Report post to moderator
    "moo moo farm gal",
    It appears you have changed your display name from a valid display name to an invalid display name. I'm confused why you would do that, since accounts with invalid display names get deleted.
    Please change your display name back soon.
    thanks,
    Dave.
     
    jakes vandenberg
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
    • Report post to moderator
    I seem to have the same issue. When I select check boxes and go to the next page I lose the checkboxes checked on the previous page. Where do I set attributes/parameters to keep the values of selected checkboxes in previous pages?

    Thanks
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • Mark post as helpful
    • send pies
    • Report post to moderator
    jakes vdb,
    OP
    Welcome to JavaRanch!

    We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

    In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

    You can change it here

    Also, you've just posted to a 3 year old thread.
    The person who started it has clearly moved on.
    If reading that thread didn't solve your problem, start a new one with a detailed description of what you're trying to do, and what you have done so far.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!