tags:

views:

277

answers:

2

I have a form bean named "SearchForm" that I use to display search results. The user then clicks on one of the element. I populate a "ElementForm" with the details of the element and generate a JSP page with it. (so far so good)

What I would like however is to display a column on the left of the JSP page with the same search results (so the user can quickly jump to another result). Doing this was easy: all I had to do was to make the SearchForm a session bean and re-use it when I generate the page that contains the details on the element.

I have the problem however when a user directly goes to an element page (from its bookmark for example). I then need to access the SearchForm and populate it with the basic search info. I just don't know how to get the form bean directly inside my MappingDispatchAction class. I tried looking inside my context, but cannot find a way to get the bean. Any idea?

A: 

In your execute method, you can do the following:

SearchForm searchForm = new SearchForm();
populateSearchFormWithDefaultValues(searchForm);
request.getSession().setAttribute("searchForm"), searchForm);

given that you refer to your SearchForm as "searchForm" in your jsp.

slipset
Thanks, that's exactly what I was looking for.
Thierry-Dimitri Roy
A: 

Thanks a lot. it save my day.

Suresh