You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Faith <fa...@runtime-collective.com> on 2001/12/05 18:54:18 UTC
action chaining without resetting action forms
Hi,
I want to 'chain' actions, by setting the forward of one to be
'my_action.do'
The problem is that this resets the action form before calling the next
action.
Is there anyway to prevent this, or am I chaining actions in the wrong
way?
thanks
--
Joe Faith
http://www.runtime-collective.com
T: (+44) 01273 234294
M: (+44) 07968 292064
Re: action chaining without resetting action forms
Posted by Paul Devine <pa...@visi.com>.
Hi Mohammed
sorry for my late reply. If you want to use use action chaining to
accomplish this, you will need to define both Action1 and Action2 mappings
in your struts-config.xml file. In the Action2 mapping, define a
<forward...> for let's call it "login_failed" which points to "/action1.do".
I can send on the exact syntax if you need that (i just don't have it with
me right now.) In Action1 mapping you will define a <forward...> to
something like "process_login" which points to your Action2 "/action2.do" .
Alternatively you could just hard code the dependency in your Action1 class,
i.e. in the perform() method of Action1, you could do a
return action2.perform( .... );
depends what makes sense in the context of your application
Please let me know if this does not help
- Paul
----- Original Message -----
From: "Mohammed" <de...@panamp.de>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 06, 2001 2:56 AM
Subject: Re: action chaining without resetting action forms
> Hi Paul,
>
> I have a similar Problem. From a link I invoke Action1 whichn sendes a
Form
> to the Browser. With a submit on this form I am invoking Action2.
> In the Action2Form I am validating the user input. In the Action2 itself I
> invoke a registeruser() methode of a database Object.
> When the username in the userfield already exist in the database I want to
> tell the user he should try another username. To do this I forward to
> Action1 again. what should I do so that the
>
> ----- Original Message -----
> From: "Paul Devine" <de...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Thursday, December 06, 2001 4:33 AM
> Subject: Re: action chaining without resetting action forms
>
>
> > Joe
> >
> > I chain actions the way you describe. When you say the action form is
> > "reset" before the next action gets to process, do you mean (a)
> specifically
> > that your ActionForm object's reset() method is invoked and you have
> > overridden that method to clear out the form? Or do you mean (b) the
> object
> > goes out of scope and a new one gets constructed by the time the second
> > action gets to process ? (or something else you are observing?) If
it's
> > (a) then I don't know of any in-built mechanisms to solve this, you may
> need
> > to write some code to manage that yourself.
> >
> > - Paul
> >
> >
> > ----- Original Message -----
> > From: "Joe Faith" <fa...@runtime-collective.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Wednesday, December 05, 2001 11:54 AM
> > Subject: action chaining without resetting action forms
> >
> >
> > > Hi,
> > >
> > > I want to 'chain' actions, by setting the forward of one to be
> > > 'my_action.do'
> > > The problem is that this resets the action form before calling the
next
> > > action.
> > > Is there anyway to prevent this, or am I chaining actions in the wrong
> > > way?
> > >
> > > thanks
> > >
> > > --
> > > Joe Faith
> > > http://www.runtime-collective.com
> > > T: (+44) 01273 234294
> > > M: (+44) 07968 292064
> > >
> > >
> > >
> >
> > --
> > 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>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Mohammed <de...@panamp.de>.
Hi Paul,
I have a similar Problem. From a link I invoke Action1 whichn sendes a Form
to the Browser. With a submit on this form I am invoking Action2.
In the Action2Form I am validating the user input. In the Action2 itself I
invoke a registeruser() methode of a database Object.
When the username in the userfield already exist in the database I want to
tell the user he should try another username. To do this I forward to
Action1 again. what should I do so that the
----- Original Message -----
From: "Paul Devine" <de...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 06, 2001 4:33 AM
Subject: Re: action chaining without resetting action forms
> Joe
>
> I chain actions the way you describe. When you say the action form is
> "reset" before the next action gets to process, do you mean (a)
specifically
> that your ActionForm object's reset() method is invoked and you have
> overridden that method to clear out the form? Or do you mean (b) the
object
> goes out of scope and a new one gets constructed by the time the second
> action gets to process ? (or something else you are observing?) If it's
> (a) then I don't know of any in-built mechanisms to solve this, you may
need
> to write some code to manage that yourself.
>
> - Paul
>
>
> ----- Original Message -----
> From: "Joe Faith" <fa...@runtime-collective.com>
> To: <st...@jakarta.apache.org>
> Sent: Wednesday, December 05, 2001 11:54 AM
> Subject: action chaining without resetting action forms
>
>
> > Hi,
> >
> > I want to 'chain' actions, by setting the forward of one to be
> > 'my_action.do'
> > The problem is that this resets the action form before calling the next
> > action.
> > Is there anyway to prevent this, or am I chaining actions in the wrong
> > way?
> >
> > thanks
> >
> > --
> > Joe Faith
> > http://www.runtime-collective.com
> > T: (+44) 01273 234294
> > M: (+44) 07968 292064
> >
> >
> >
>
> --
> 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: action chaining without resetting action forms
Posted by Paul Devine <de...@hotmail.com>.
Joe
I chain actions the way you describe. When you say the action form is
"reset" before the next action gets to process, do you mean (a) specifically
that your ActionForm object's reset() method is invoked and you have
overridden that method to clear out the form? Or do you mean (b) the object
goes out of scope and a new one gets constructed by the time the second
action gets to process ? (or something else you are observing?) If it's
(a) then I don't know of any in-built mechanisms to solve this, you may need
to write some code to manage that yourself.
- Paul
----- Original Message -----
From: "Joe Faith" <fa...@runtime-collective.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, December 05, 2001 11:54 AM
Subject: action chaining without resetting action forms
> Hi,
>
> I want to 'chain' actions, by setting the forward of one to be
> 'my_action.do'
> The problem is that this resets the action form before calling the next
> action.
> Is there anyway to prevent this, or am I chaining actions in the wrong
> way?
>
> thanks
>
> --
> Joe Faith
> http://www.runtime-collective.com
> T: (+44) 01273 234294
> M: (+44) 07968 292064
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Volker Krebs <vo...@abas.de>.
Ted Husted wrote:
> Volker Krebs wrote:
>
>>I'm intrested, can you please post a patched JAR.
>>We are doing some Action chaning in our application.
>>
> OK, see
> http://husted.com/struts/resources/invoke.zip
Sorry, but with your patched struts.jar my Application
won't deploy.
NoClassDefFoundError: org/apache/struts/action/ActionMessages
I'm using Tomcat 3.2.3 on Win2000.
Also I had to make the invokeAction Method public.
But the solution Paul Devine suggested:
return action2.perform( .... );
is almost what I wanted to do. (Pass a diffrent formBean with my
action).
Volker
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Ted Husted <hu...@apache.org>.
Volker Krebs wrote:
> I'm intrested, can you please post a patched JAR.
> We are doing some Action chaning in our application.
OK, see
http://husted.com/struts/resources/invoke.zip
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Volker Krebs <vo...@abas.de>.
Hi,
> For the nightly build, I've suggested that we add two new methods so
> that one Action can invoke another, but need some people to test the
> idea for me. (Since I don't do this sort of thing myself.)
>
> If anyone is interested, I can post a patched JAR. But then they really,
> really need to tell me that it works, or else this will never be
> committed.
I'm intrested, can you please post a patched JAR.
We are doing some Action chaning in our application.
>>I want to 'chain' actions, by setting the forward of one to be
>>'my_action.do'
>>The problem is that this resets the action form before calling the next
>>action.
In our Application this works fine. If I forward from one Action
to another Action,
the form Bean is still known in the second Action.
But this might be, because both Actions use the same FormBean
in their struts-config name tag as default FormBean.
Volker
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Volker Krebs <vo...@abas.de>.
Hello Ted,
> If anyone is interested, I can post a patched JAR. But then they really,
> really need to tell me that it works, or else this will never be
> committed.
I've finally managed to test it. I had to integrated
in the newest nightly build, because we are using
some new tags. But after that it worked fine in our Application.
It still has to be integrated in the ActionServlet for
tiles (ActionComponentServlet), and the invokeAction method
has to become public.
I would appreciate if this would be committed.
thanks,
Volker
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: action chaining without resetting action forms
Posted by Ted Husted <hu...@apache.org>.
The best solution here is to use add a switch to your bean to make its
properties immutable.
private boolean immutable = false;
public void setImmutable(boolean immutable) {
this.immutable = immutable;
}
// ...
public setProperty(String property) {
if (immutable) exit;
this.property = property;
If you set this before forwarding the bean, then reset and autopopulate
will have no affect.
(Unless, of course, reset sets the fields directly. In which case, reset
needs to observe immutable, or use the setters instead.)
For the nightly build, I've suggested that we add two new methods so
that one Action can invoke another, but need some people to test the
idea for me. (Since I don't do this sort of thing myself.)
This would let you do things like
// ...
ActionForward forward =
servlet.invokeAction("/item/Edit",form,request,response);
return forward;
To create a new ActionForm to use with invokeAction, you could call
ActionForm secondForm =
servlet.createActionForm("/item/Edit");
and then populate it as you would any ActionForm:
ActionForward forward = null;
if (secondForm==null) {
// .. cope with error
}
else {
EditForm editForm = (EditForm) secondForm;
editForm.setArticle("17");
editForm.setTitle("Change Me");
forward = invokeAction(
"/item/Edit",editForm,request,response);
}
// ...
return forward;
If anyone is interested, I can post a patched JAR. But then they really,
really need to tell me that it works, or else this will never be
committed.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
Joe Faith wrote:
>
> Hi,
>
> I want to 'chain' actions, by setting the forward of one to be
> 'my_action.do'
> The problem is that this resets the action form before calling the next
> action.
> Is there anyway to prevent this, or am I chaining actions in the wrong
> way?
>
> thanks
>
> --
> Joe Faith
> http://www.runtime-collective.com
> T: (+44) 01273 234294
> M: (+44) 07968 292064
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>