You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Max Kremer <mk...@datastay.com> on 2002/12/27 20:38:10 UTC

Forwarding to an Action and changing the ActionForm data

Hello,

   Here's my problem, I have two Actions, both use the same form bean as
follows from the config:

<action path="/createnew"  type="PartCreateAction"  name="partListForm"
scope="request"  input="/NewPart.jsp" />

<action path="/partlist"  type="PartListAction"  name="partListForm"
scope="request" input="/MainMenu.jsp" />

I start with first action and then always forward to the second. In the
first action I change some of the form bean properties by calling its setter
methods before I forward to the second action. However, the second action
doesn't see the changes I made to the form bean properties.Why? Aren't they
both using the same instance of the form bean for the duration of the
request????? If not, how do I accomplish this?
Please help.

Thanks ,
MAX


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


Can you use the Validator with Map-Backed ActionForms?

Posted by Max Kremer <mk...@datastay.com>.
I'm currently using Map-backed forms to manage forms that are dynamically
created from a database, where the number of fields, their names, their
types are not necessarily known at deployment (so no DynaActionForm). I'm
wondering if it's still possible to use the (Commons) Validator to validate
the form fields.

I understand that the normal usage requires form elements in the
validator-rules file to match that of a form-bean element in the Struts
config file. That's not really possible in my case because I don't know
ahead of time what the fields will be (by name or type, in number, etc.).
Would it be possible to programmatically create the formset and form
elements Validator requires but still use them in conjunction with the
validations file (where the validator elements are stored), which would be
commonly shared between forms? Any pointers on how I can accomplish this?
Or, is there a better way to handle dynamic (i.e., on-the-fly or real-time)
form creation with Struts?





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


Re: Forwarding to an Action and changing the ActionForm data

Posted by Max Kremer <mk...@datastay.com>.
But when you forward the request from one action to another with a
"mapping.findForward( )" doesn't this have the effect of passing an existent
request object directly from one action to the other? And isn't the
ActionForm contained within the request object?

----- Original Message -----
From: "James Mitchell" <jm...@apache.org>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Saturday, December 28, 2002 11:14 AM
Subject: RE: Forwarding to an Action and changing the ActionForm data


> Your ActionForm's are reconstituted from the request with each action.
> This is by design, since the forward is occuring within the container,
> there is no way for Struts to know that you just forwarded from a
> previous action.
>
> Try setting your form at Session scope.
>
>
> --
> James Mitchell
> Software Engineer/Open Source Evangelist
> http://www.open-tools.org
>
> "C makes it easy to shoot yourself in the foot; C++ makes it harder, but
> when you do, it blows away your whole leg."
> - Bjarne Stroustrup
>
>
> > -----Original Message-----
> > From: Max Kremer [mailto:mkremer@datastay.com]
> > Sent: Friday, December 27, 2002 2:38 PM
> > To: Struts Users Mailing List
> > Subject: Forwarding to an Action and changing the ActionForm data
> >
> >
> > Hello,
> >
> >    Here's my problem, I have two Actions, both use the same
> > form bean as
> > follows from the config:
> >
> > <action path="/createnew"  type="PartCreateAction"
> > name="partListForm"
> > scope="request"  input="/NewPart.jsp" />
> >
> > <action path="/partlist"  type="PartListAction"  name="partListForm"
> > scope="request" input="/MainMenu.jsp" />
> >
> > I start with first action and then always forward to the
> > second. In the
> > first action I change some of the form bean properties by
> > calling its setter
> > methods before I forward to the second action. However, the
> > second action
> > doesn't see the changes I made to the form bean
> > properties.Why? Aren't they
> > both using the same instance of the form bean for the duration of the
> > request????? If not, how do I accomplish this?
> > Please help.
> >
> > Thanks ,
> > MAX
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> > For
> > additional commands,
> > e-mail: <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> -
>
>


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


RE: Forwarding to an Action and changing the ActionForm data

Posted by James Mitchell <jm...@apache.org>.
Your ActionForm's are reconstituted from the request with each action.
This is by design, since the forward is occuring within the container,
there is no way for Struts to know that you just forwarded from a
previous action.

Try setting your form at Session scope.


--
James Mitchell
Software Engineer/Open Source Evangelist
http://www.open-tools.org

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg." 
- Bjarne Stroustrup


> -----Original Message-----
> From: Max Kremer [mailto:mkremer@datastay.com] 
> Sent: Friday, December 27, 2002 2:38 PM
> To: Struts Users Mailing List
> Subject: Forwarding to an Action and changing the ActionForm data
> 
> 
> Hello,
> 
>    Here's my problem, I have two Actions, both use the same 
> form bean as
> follows from the config:
> 
> <action path="/createnew"  type="PartCreateAction"  
> name="partListForm"
> scope="request"  input="/NewPart.jsp" />
> 
> <action path="/partlist"  type="PartListAction"  name="partListForm"
> scope="request" input="/MainMenu.jsp" />
> 
> I start with first action and then always forward to the 
> second. In the
> first action I change some of the form bean properties by 
> calling its setter
> methods before I forward to the second action. However, the 
> second action
> doesn't see the changes I made to the form bean 
> properties.Why? Aren't they
> both using the same instance of the form bean for the duration of the
> request????? If not, how do I accomplish this?
> Please help.
> 
> Thanks ,
> MAX
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 
> 


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