You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Henrique Alves Lima <em...@yahoo.com.br> on 2004/03/06 23:19:07 UTC

1 request & 2 forms

Hi.

Can i use the struts mechanism to fill 2 *different* action forms from 1 
http request ?
I've a button in a .jsp page. When the user to press this button, i need 
to save a session scoped form before forward to a new page (the new page 
uses another form). Is is possible ?

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: 1 request & 2 forms

Posted by Daniel Henrique Alves Lima <em...@yahoo.com.br>.
    Solved !
    I don't know why but when i use multipart-form i get an error while 
populating the second form (like the case of Guillermo). Then i've 
removed enctype from html:form and everything works !

**Case 2** source.jsp -> AAction (AForm) -> BAction (BForm) -> 
destiny.jsp (BForm)

    Where AAction is only a org.apache.struts.actions.ForwardAction...

Thanks !



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: 1 request & 2 forms

Posted by Guillermo Meyer <gm...@interbanking.com.ar>.
Struts fills Forms attributes before invoking an action.
How are you chaining these actions?
In case 2:
Source.jsp post to Aaction. Aform is populated with request parameters
and execute in Aaction is called. You do something with this and then,
returns an actionForward that as "Baction.do". So, you "chain" these
actions, and Struts is invoked again with this actionForward. The
request is the same (do not do any redirect) so Struts populates Bform
Asociated to Baction and fills it with the same request parameters as in
Aform.

Are you configuring mappings like this?

<action path="/AAction" type="mypackage.AAction" name="AForm">
	<forward name="BAction" path="/BAction.do"/> <!-- if you use
redirect, request is lost and parameters are not filled.-->
</action>

<action path="/BAction" type="mypackage.BAction" name="BForm">
	<forward name="destiny" path="/destiny.jsp"/>
</action>

May you are either calling Baction in other way or are using a redirect
between them, are you?

Cheers.
Guillermo.

-----Original Message-----
From: Daniel Henrique Alves Lima [mailto:email_daniel_h@yahoo.com.br] 
Sent: Sábado, 06 de Marzo de 2004 08:11 p.m.
To: Struts Users Mailing List
Subject: Re: 1 request & 2 forms


Ok :-)

    I have 2 .jsp files (source.jsp and destiny.jsp). Between these two,

i put an action (let's call it BAction). Either destiny.jsp and B action

were expecting a BForm. So :

            **Case 1** source.jsp -> BAction (BForm) -> destiny.jsp
(BForm)

    Now, i want to insert a new action (AAction) between source.jsp and 
BAction. My AAction will use a AForm, like :

            **Case 2** source.jsp -> AAction (AForm) -> BAction (BForm) 
-> destiny.jsp (BForm)

    But i want to struts automatic fills the properties of AForm and 
BForm with the parameters from my http request.
    I don't know why but, at case 2, when BAction receives BForm, its 
properties have just null values...

    Any glue ? I think i will use BeanUtils to fill the properties of 
the second form (B form)...


                         Thanks !

Geeta Ramani wrote:

>Sorry, that wasn't how I understood your question.. and i'm not sure I 
>*do* understand your question now either.. would you explain your 
>problem and what you are trying to do once again..?
>
>Daniel Henrique Alves Lima wrote:
>
>  
>
>>Yes, i got a error.
>>
>>I've just added a "org.apache.struts.actions.ForwardAction" (to struts

>>initializes and populates the session scoped form -> named A) between 
>>the .jsp file (which contains the button) and a previous existent 
>>action (the one which receives a new request scoped form -> named B). 
>>Now, the attributes of B form are empty (i'm getting null values)...
>>
>>Any idea ?
>>
>>Geeta Ramani wrote:
>>
>>    
>>
>>>I have never done this but i don't see why not.  When you press your 
>>>submit button on your jsp, an Action is called, right?  You can do 
>>>whatever you want in that execute method would be my guess.  So if 
>>>you feel like saving one form in session scope and another in in 
>>>request attribute before you forward to your new page, i don't see 
>>>why you shouldn't be able to..  Do you envision a problem?
>>>
>>>Geeta
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido exclusivamente a las personas direccionadas en el mail y puede contener informacion (i)de propiedad exclusiva de Interbanking S.A. o (ii) amparada por el secreto profesional. Cualquier opinion en el contenido, es exclusiva de su autor y no representa necesariamente la opinion de Interbanking S.A. El acceso no autorizado, uso, reproduccion, o divulgacion esta prohibido. Interbanking S.A no asumira responsabilidad ni obligacion legal alguna por cualquier informacion incorrecta o alterada contenida en este mensaje. Si usted ha recibido este mensaje por error, le rogamos tenga la amabilidad de destruirlo inmediatamente junto con todas las copias del mismo, notificando al remitente. No debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni ninguna de sus partes si usted no es el destinatario. Muchas gracias.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: 1 request & 2 forms

Posted by Daniel Henrique Alves Lima <em...@yahoo.com.br>.
Ok :-)

    I have 2 .jsp files (source.jsp and destiny.jsp). Between these two, 
i put an action (let's call it BAction). Either destiny.jsp and B action 
were expecting a BForm. So :

            **Case 1** source.jsp -> BAction (BForm) -> destiny.jsp (BForm)

    Now, i want to insert a new action (AAction) between source.jsp and 
BAction. My AAction will use a AForm, like :

            **Case 2** source.jsp -> AAction (AForm) -> BAction (BForm) 
-> destiny.jsp (BForm)

    But i want to struts automatic fills the properties of AForm and 
BForm with the parameters from my http request.
    I don't know why but, at case 2, when BAction receives BForm, its 
properties have just null values...

    Any glue ? I think i will use BeanUtils to fill the properties of 
the second form (B form)...


                         Thanks !

Geeta Ramani wrote:

>Sorry, that wasn't how I understood your question.. and i'm not sure I *do*
>understand your question now either.. would you explain your problem and what you
>are trying to do once again..?
>
>Daniel Henrique Alves Lima wrote:
>
>  
>
>>Yes, i got a error.
>>
>>I've just added a "org.apache.struts.actions.ForwardAction" (to struts
>>initializes and populates the session scoped form -> named A) between
>>the .jsp file (which contains the button) and a previous existent action
>>(the one which receives a new request scoped form -> named B). Now, the
>>attributes of B form are empty (i'm getting null values)...
>>
>>Any idea ?
>>
>>Geeta Ramani wrote:
>>
>>    
>>
>>>I have never done this but i don't see why not.  When you press your submit
>>>button on your jsp, an Action is called, right?  You can do whatever you
>>>want in that execute method would be my guess.  So if you feel like saving
>>>one form in session scope and another in in request attribute before you
>>>forward to your new page, i don't see why you shouldn't be able to..  Do you
>>>envision a problem?
>>>
>>>Geeta
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: 1 request & 2 forms

Posted by Geeta Ramani <ge...@cmpco.com>.
Sorry, that wasn't how I understood your question.. and i'm not sure I *do*
understand your question now either.. would you explain your problem and what you
are trying to do once again..?

Daniel Henrique Alves Lima wrote:

> Yes, i got a error.
>
> I've just added a "org.apache.struts.actions.ForwardAction" (to struts
> initializes and populates the session scoped form -> named A) between
> the .jsp file (which contains the button) and a previous existent action
> (the one which receives a new request scoped form -> named B). Now, the
> attributes of B form are empty (i'm getting null values)...
>
> Any idea ?
>
> Geeta Ramani wrote:
>
> >I have never done this but i don't see why not.  When you press your submit
> >button on your jsp, an Action is called, right?  You can do whatever you
> >want in that execute method would be my guess.  So if you feel like saving
> >one form in session scope and another in in request attribute before you
> >forward to your new page, i don't see why you shouldn't be able to..  Do you
> >envision a problem?
> >
> >Geeta
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: 1 request & 2 forms

Posted by Daniel Henrique Alves Lima <em...@yahoo.com.br>.
Yes, i got a error.

I've just added a "org.apache.struts.actions.ForwardAction" (to struts 
initializes and populates the session scoped form -> named A) between 
the .jsp file (which contains the button) and a previous existent action 
(the one which receives a new request scoped form -> named B). Now, the 
attributes of B form are empty (i'm getting null values)...

Any idea ?

Geeta Ramani wrote:

>I have never done this but i don't see why not.  When you press your submit
>button on your jsp, an Action is called, right?  You can do whatever you
>want in that execute method would be my guess.  So if you feel like saving
>one form in session scope and another in in request attribute before you
>forward to your new page, i don't see why you shouldn't be able to..  Do you
>envision a problem?
>
>Geeta
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: 1 request & 2 forms

Posted by Geeta Ramani <ge...@cmpco.com>.
I have never done this but i don't see why not.  When you press your submit
button on your jsp, an Action is called, right?  You can do whatever you
want in that execute method would be my guess.  So if you feel like saving
one form in session scope and another in in request attribute before you
forward to your new page, i don't see why you shouldn't be able to..  Do you
envision a problem?

Geeta

Daniel Henrique Alves Lima wrote:

> Hi.
>
> Can i use the struts mechanism to fill 2 *different* action forms from 1
> http request ?
> I've a button in a .jsp page. When the user to press this button, i need
> to save a session scoped form before forward to a new page (the new page
> uses another form). Is is possible ?
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org