You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Lehrian <ml...@crosscurrent.com> on 2002/07/16 22:36:38 UTC

Passing form objects between actions?

Hi,

I have a situation where I have a jsp that invokes an action with form.  
That action forwards to a second action that uses the form of the next 
jsp in the chain.  I need access to the first form from within the 
second action.  It seems "sometimes" I can get the first form with a 
request.getAttribute("formName") call from within the 2nd action, but it 
doesn't always work.  Can anyone explain if this is a doable thing?

Ex.

+----------------+             +------------------+             
+------------------+             +----------------+
  |                      |               |  Page1 
Post  |               |  Page2 
Pre   |               |                      |
  |  page1.jsp  |   ----->   |     Process     |   ----->   |     
Process     |   ----->   |  page2.jsp  |
  |                      |               |      
Action       |               |       
Action       |               |                      |
+----------------+             +------------------+             
+------------------+             +----------------+
                                                      |                   
                       |
                                                      |                   
                       |
                                                      |                   
                       |
                                         +----------------+               
    +--------------+
                                          |     
Page1     |                    |    Page2   |
                                          |      
Form       |                    |     Form     |
                                         +----------------+               
    +--------------+

The Page1PostProcessAction creates a database record, which generates a 
primary key which is set in Page1Form.  Page2PreProcessAction needs 
access to the primary key.  From examing the Struts code, Page1Form 
would appear to be set into the request attributes under the attribute 
(or name, if attribute is null) value defined for the action.  
Sometimes, from within Page2PreProcessAction, I can call 
request.getAttribute("page1Form") and it return me the form.  Other 
times, it is null.

Is this "supported" functionality?  Should I not be doing this?  Any 
suggestion on how to avoid this?  I thought about manually modifying the 
URI and appending a querystring (as someone was talking about earlier 
today) but sometime I have a lot of data I need from the previous form 
and that would be a bit cumbersome and maintenance-intensive.

Thanks for you help!
Matthew


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>