|
I am trying to set a form bean in session so it can be used
accross Action classes. Specifically, I am trying to get the form bean to
remember a value so it can repopulate the jsp page accordingly when that page
appears again (if the user hits 'cancel').
My assumption: that setting
<action name="testForm" scope="session" ... > would put the form bean
referenced by 'testForm' into session scope.
This assumption is either wrong, or there is a bug in struts,
or I am doing something else wrong.
My struts config:
<form-bean name="testForm"
type="[path].TestForm"/>
<action path="/test1"
type="[path].Test1Action"
name="testForm"
scope="session"
validate="true"
input="/[path]/test1.jsp">
[forwards] </action> <action
path="/test2"
type="[path].Test2Action" name="[another form]" scope="request" validate="true" input="/[path/test2.jsp"> [forwards] <forward name="cancel" path="/[path]/test1.jsp"/> </action> Action test1.do loads first. A submit button loads
Action test2.do, and it is in Test2Action that I attempt to recieve the form
(testForm) that was supposedly put into session from test1.do.
I failed to figure out the name the form was given in the
session, so I output all of the types of objects currently in session.
Here is my code (in Test2Action):
System.out.println("*** AttributeName List:
***");
for(Enumeration e = request.getSession().getAttributeNames(); e.hasMoreElements(); ) { System.out.println("*** e.nextElement()=" + e.nextElement() + " ***"); } And here is the output:
*** AttributeName List: ***
*** e.nextElement()=user
***
*** e.nextElement()=org.apache.struts.action.LOCALE *** As you can see, the form bean was not put into session by the
struts-config file (user we explicitely put into session). Either that, or
I am misunderstanding something (it happens).
Could someone give me some advice on this?
Thanks,
|
- Re: Problems setting form in session Eric Rasmussen
- Re: Problems setting form in session Rob Leland
- Re: Problems setting form in session Eric Rasmussen

