One solution is to persist the data bean in the session scope. I've just
done this by giving the bean a unique name by appending the sessionId and
sending it back into the session scope, as well as sending a clone of the
bean into the request scope to be used by View A.
The follow-on action, Action B, looks for this unique bean name in the
session, and passes it on to helper beans that extract new data using it
from the Model. Action B then removes the bean from the session scope.
Appending the sessionId solves the synchronization issue, but not the
memory problem - these beans could accumulate in the session scope if the
Action removing them isn't called.
It works, but isn't clean. Can anyone suggest something better?
Iain.
Iain Sanderson [EMAIL PROTECTED]
05/28/2003 07:11 AM
Please respond to Struts Users Mailing List
To: [EMAIL PROTECTED]
cc:
Subject:Howto forward bean from one action to another in
the request scope?
I have a struts app in which I use an action (say action A) to pass a
bean (Bean A) containing data from the Model as an attribute in the
request scope to a View ( JSP A).
JSP A contains a Form that initiates Action B ( simply a Submit button)
and thus on to View B(JSP B) after some more interaction with the Model.
What I would like to do is re-use Bean A in Action B, as it contains data
pertinent to Action B, and I don't want to query the model again for the
same data.
How can I do this keeping the data bean A in the request scope? I know I
can achieve this by placing Bean A in the session scope, but this will
accumulate memory and cause potential synchronization problems accross
multiple users.
The real life scenario is this- Action A is selecting Patient cases from a
database corresponding to a date range, and displaying the Case list data
(Bean A) in a table (JSP A) . The next task is to display all the pharmacy
bills for the set of cases defined in Bean A and shown in JSP A. So I
would like to pass Bean A to the next Action B, which would forward the
caselist to a helper bean, which in turn would query the Model for all
the drugs used for all the patients defined in Bean A. The end result is a
list of pharmacy Bills (View B) which would print out as all the bills
for patients in a date range defined by the selection started by Action A.
Any help gratefully received.