aspose file tools*
The moose likes Struts and the fly likes Sustaining formbean attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sustaining formbean attributes" Watch "Sustaining formbean attributes" New topic
Author

Sustaining formbean attributes

Mohit Jain
Ranch Hand

Joined: Jun 04, 2007
Posts: 74
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.


SCJP 5.0, SCWCD in progress
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jun 04, 2007
Posts: 74
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sustaining formbean attributes