• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Persisting Drop down Value Between Screens

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp page which shows customer information . As the number of records can be numerous we have implemented pagination (20 records on a page) . So user can hit on first next ,last , previous . now on each row in the customer record I have a drop down(combo box) . Now what I want is that when user selects something in the combo box and navigates to the next page and then comes back he should get all the selected values in place . can smbody propose some method of doing this..
 
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the selected attribute on the option that is to be selected in the dropdown.
 
Rohit Dhodapkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear how do I store these selections ? . I mean should I store them in session,request or some other thing . If yes How should I go about it..
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you are using strictly servlet, and the selection from the form goes from jsp -> servlet -> jsp, using the request parameters is usually ok.

since you want to have things selected,then go to another page, then come back to this page and have them selected again, storing on the session attribute is probably more helpful; otherwise you would have to implement the hidden fields on the second page to store the values, this is not a good thing to maintain.

i assume from having a select on each row of the table would mean you need to have dynamic / different names for each row (i.e. select_1, select_2).

I would then recommend making a bean, perhaps just an instance of a hashtable, and stuffing this onto the session attributes, and it will contain the state for all the select options on your screen.
this way
- there is only 1 session attribute to get for each list screen, the values of the hashtable key: the name of the select / combo box, value: the id of the selected option.
- if you have other table list screens that would possibly have different sets of selected things in the future, each of screen can can store the selected combobox values independently
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic