Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sustaining formbean attributes

 
Mohit Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If we want to retain some attribute values across multiple pages which is a better approach -

1. Declare the required formbean attributes as static.
2. Put the formbean into session scope.

I have a list of records showing on Page1, when user clicks on any record, a few parameters are passed to targetted action class.
I do not want those parameters to be displayed in URL query string.
Also I feel its not a good practice to keep entire record list in session.

Please suggest.. Will it help to keep the records as static arraylist in formbean.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session. If it's static and your application has more than one user wouldn't that lead to issues? Static members are per class, not per instance.
 
Mohit Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response David. Well if we put entire list of records in session is it a good practice?
Please suggest what kinda problems may be encoutered following this.

Is there any better way to do this??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can lead to large sessions if the collections are very large; in those cases you should only return a page's worth of results and re-query on pagination.

Whether or not it's a "best practice" depends on the situation, really.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic