aspose file tools*
The moose likes Struts and the fly likes session scope, forms and threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "session scope, forms and threads" Watch "session scope, forms and threads" New topic
Author

session scope, forms and threads

D. Clarke
Greenhorn

Joined: May 09, 2006
Posts: 25
Good day -

I have the following Struts flow:

define search -> search/store results in session -> intersitial -> JSP showing results from search -> selecting a result -> viewing details of search

I have a threaded class that puts a set of results in the session under a key. I am not sure if it is better to just put the result set into the session from the original action class (and passing it to the search class), or trying to add it to a form that I will use later. It seems that whichever way I do it isn't really elegant. I have the form as session scope, but because the results form isn't created until after the search is done, that doesn't really help me.

Thank you for your help
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Why not just add the result set as a property in your session-scoped ActionForm bean? Then, just allow it to be null until the search process is complete. Your JSP can use <logic:notEmpty> to determine whether to display it or not.


Merrill
Consultant, Sima Solutions
D. Clarke
Greenhorn

Joined: May 09, 2006
Posts: 25
Can you do that if you have different Forms? I have a form that has the original request data, then I move to the search form and then to the display results form. Are you saying to just keep the one request form, with a attribute for results that is null until the search is complete?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you have different ActionForms for each action, then no, this technique will not work.
Are you saying to just keep the one request form, with a attribute for results that is null until the search is complete?

Yes, That's exactly what I'm saying. That's how I normally handle searches. I typically even use the same JSP for both entering search criteria and displaying results. I just put <logic:notEmpty></logic:notEmpty> tags around the result table so that it's only visible if there are results to display.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session scope, forms and threads