Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session scope, forms and threads

 
D. Clarke
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
D. Clarke
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic