You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oleg <ol...@gmail.com> on 2005/11/15 04:09:24 UTC

Posting from 1JSP to 2Actions and 2Forms

Hi,

I found a long thread talking about one jsp, two action, two action
forms. However my situation is a bit different and suggested solutions
would not work, plus I didn't want resurrect an old thread :)

I have:

Jsp A -> Action A (ActionForm A)

Now there are occasions when I need another action, Action B executed
before Action A but I can only use one jsp page. So what I would have
is:

Jsp AB - Action B(ActionForm B) ->Action A(ActionForm A)

Where Jsp AB has information to populate both ActionForms A and B.
Both ActionForms are session scope.

Option 1. Would be to manually populate  ActionForm A in Action B, but
I would like to avoid that since there will be other possible Actions
similar to Action B(ActionForm B), so Action C, Action D all ending up
calling Action A(ActionForm A) and I don't want to change all of them
every time ActionForm A changes.

Option 2. What if I ActionForm B extends ActionForm A and than it
becomes something like:
Jsp AB - Action B(ActionForm B) ->Action A { ...ActionForm A =
(ActionForm A)ActionForm B..}

This could work but than I am out of luck when I need to use a
DynaValidatorForm as ActionForm C in  Action C(ActionForm C) - >
Action A(ActionForm A)

What do you think guys? Whats the best way to go about it.

Thanks,
Oleg

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Michael Jouravlev <jm...@gmail.com>.
Umm, no. I remember I did some experiments with action chaining with
different scopes. I either defined forms for both actions or as a
second option I did not define one of the forms. I do not remember
were these forms with the same name or not. I cannot find the results.

You might try it yourself or just trace the code. But if the request
data is not populated into second form automatically you may try to
stick data from the first form into request object and see what
happens :)

They are not supposed to work this way.

Michael

On 11/17/05, Oleg <ol...@gmail.com> wrote:
> Michael, I tried that, however it seems to work only if actions are
> using same ActionForm if lets say each action uses its own form, the
> second action gets the form with its original values (from session)
> without any changes taken from the JSP page. Any ideas?
>
> Thanks
> Oleg
>
> On 11/16/05, Oleg <ol...@gmail.com> wrote:
> > Hehe I see, but unfortunatelly its the only way I can see how to
> > implement this kind of functionality. The only way to avoid chaining
> > here would be to separate this one jsp page in two and have client
> > input form in two different steps. Problem is that this is not what
> > client wants :) so chaining it is
> >
> > Oleg
> >
> > On 11/15/05, Michael Jouravlev <jm...@gmail.com> wrote:
> > > If I remember correctly, when you either forward or redirect from one
> > > action to another, Struts performs the reset/populate/validate
> > > sequence again. If you redirect, the request is empty, so nothing to
> > > populate and the form corresponding to second action is not updated.
> > > But if you forward from one action to another, the request object
> > > still retains the input data, and is applied to the second form. If
> > > your second form has setters and they are compatible name-wize with
> > > input parameters, they will be set.
> > >
> > > On the other hand, what you want to do is a clear example of action
> > > chaining which is frowned upon ;-)
> > >
> > > Michael.
> > >
> > > On 11/14/05, Oleg <ol...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I found a long thread talking about one jsp, two action, two action
> > > > forms. However my situation is a bit different and suggested solutions
> > > > would not work, plus I didn't want resurrect an old thread :)
> > > >
> > > > I have:
> > > >
> > > > Jsp A -> Action A (ActionForm A)
> > > >
> > > > Now there are occasions when I need another action, Action B executed
> > > > before Action A but I can only use one jsp page. So what I would have
> > > > is:
> > > >
> > > > Jsp AB - Action B(ActionForm B) ->Action A(ActionForm A)
> > > >
> > > > Where Jsp AB has information to populate both ActionForms A and B.
> > > > Both ActionForms are session scope.
> > > >
> > > > Option 1. Would be to manually populate  ActionForm A in Action B, but
> > > > I would like to avoid that since there will be other possible Actions
> > > > similar to Action B(ActionForm B), so Action C, Action D all ending up
> > > > calling Action A(ActionForm A) and I don't want to change all of them
> > > > every time ActionForm A changes.
> > > >
> > > > Option 2. What if I ActionForm B extends ActionForm A and than it
> > > > becomes something like:
> > > > Jsp AB - Action B(ActionForm B) ->Action A { ...ActionForm A =
> > > > (ActionForm A)ActionForm B..}
> > > >
> > > > This could work but than I am out of luck when I need to use a
> > > > DynaValidatorForm as ActionForm C in  Action C(ActionForm C) - >
> > > > Action A(ActionForm A)
> > > >
> > > > What do you think guys? Whats the best way to go about it.
> > > >
> > > > Thanks,
> > > > Oleg
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Oleg <ol...@gmail.com>.
Michael, I tried that, however it seems to work only if actions are
using same ActionForm if lets say each action uses its own form, the
second action gets the form with its original values (from session)
without any changes taken from the JSP page. Any ideas?

Thanks
Oleg

On 11/16/05, Oleg <ol...@gmail.com> wrote:
> Hehe I see, but unfortunatelly its the only way I can see how to
> implement this kind of functionality. The only way to avoid chaining
> here would be to separate this one jsp page in two and have client
> input form in two different steps. Problem is that this is not what
> client wants :) so chaining it is
>
> Oleg
>
> On 11/15/05, Michael Jouravlev <jm...@gmail.com> wrote:
> > If I remember correctly, when you either forward or redirect from one
> > action to another, Struts performs the reset/populate/validate
> > sequence again. If you redirect, the request is empty, so nothing to
> > populate and the form corresponding to second action is not updated.
> > But if you forward from one action to another, the request object
> > still retains the input data, and is applied to the second form. If
> > your second form has setters and they are compatible name-wize with
> > input parameters, they will be set.
> >
> > On the other hand, what you want to do is a clear example of action
> > chaining which is frowned upon ;-)
> >
> > Michael.
> >
> > On 11/14/05, Oleg <ol...@gmail.com> wrote:
> > > Hi,
> > >
> > > I found a long thread talking about one jsp, two action, two action
> > > forms. However my situation is a bit different and suggested solutions
> > > would not work, plus I didn't want resurrect an old thread :)
> > >
> > > I have:
> > >
> > > Jsp A -> Action A (ActionForm A)
> > >
> > > Now there are occasions when I need another action, Action B executed
> > > before Action A but I can only use one jsp page. So what I would have
> > > is:
> > >
> > > Jsp AB - Action B(ActionForm B) ->Action A(ActionForm A)
> > >
> > > Where Jsp AB has information to populate both ActionForms A and B.
> > > Both ActionForms are session scope.
> > >
> > > Option 1. Would be to manually populate  ActionForm A in Action B, but
> > > I would like to avoid that since there will be other possible Actions
> > > similar to Action B(ActionForm B), so Action C, Action D all ending up
> > > calling Action A(ActionForm A) and I don't want to change all of them
> > > every time ActionForm A changes.
> > >
> > > Option 2. What if I ActionForm B extends ActionForm A and than it
> > > becomes something like:
> > > Jsp AB - Action B(ActionForm B) ->Action A { ...ActionForm A =
> > > (ActionForm A)ActionForm B..}
> > >
> > > This could work but than I am out of luck when I need to use a
> > > DynaValidatorForm as ActionForm C in  Action C(ActionForm C) - >
> > > Action A(ActionForm A)
> > >
> > > What do you think guys? Whats the best way to go about it.
> > >
> > > Thanks,
> > > Oleg
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Oleg <ol...@gmail.com>.
Hehe I see, but unfortunatelly its the only way I can see how to
implement this kind of functionality. The only way to avoid chaining
here would be to separate this one jsp page in two and have client
input form in two different steps. Problem is that this is not what
client wants :) so chaining it is

Oleg

On 11/15/05, Michael Jouravlev <jm...@gmail.com> wrote:
> If I remember correctly, when you either forward or redirect from one
> action to another, Struts performs the reset/populate/validate
> sequence again. If you redirect, the request is empty, so nothing to
> populate and the form corresponding to second action is not updated.
> But if you forward from one action to another, the request object
> still retains the input data, and is applied to the second form. If
> your second form has setters and they are compatible name-wize with
> input parameters, they will be set.
>
> On the other hand, what you want to do is a clear example of action
> chaining which is frowned upon ;-)
>
> Michael.
>
> On 11/14/05, Oleg <ol...@gmail.com> wrote:
> > Hi,
> >
> > I found a long thread talking about one jsp, two action, two action
> > forms. However my situation is a bit different and suggested solutions
> > would not work, plus I didn't want resurrect an old thread :)
> >
> > I have:
> >
> > Jsp A -> Action A (ActionForm A)
> >
> > Now there are occasions when I need another action, Action B executed
> > before Action A but I can only use one jsp page. So what I would have
> > is:
> >
> > Jsp AB - Action B(ActionForm B) ->Action A(ActionForm A)
> >
> > Where Jsp AB has information to populate both ActionForms A and B.
> > Both ActionForms are session scope.
> >
> > Option 1. Would be to manually populate  ActionForm A in Action B, but
> > I would like to avoid that since there will be other possible Actions
> > similar to Action B(ActionForm B), so Action C, Action D all ending up
> > calling Action A(ActionForm A) and I don't want to change all of them
> > every time ActionForm A changes.
> >
> > Option 2. What if I ActionForm B extends ActionForm A and than it
> > becomes something like:
> > Jsp AB - Action B(ActionForm B) ->Action A { ...ActionForm A =
> > (ActionForm A)ActionForm B..}
> >
> > This could work but than I am out of luck when I need to use a
> > DynaValidatorForm as ActionForm C in  Action C(ActionForm C) - >
> > Action A(ActionForm A)
> >
> > What do you think guys? Whats the best way to go about it.
> >
> > Thanks,
> > Oleg
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Michael Jouravlev <jm...@gmail.com>.
If I remember correctly, when you either forward or redirect from one
action to another, Struts performs the reset/populate/validate
sequence again. If you redirect, the request is empty, so nothing to
populate and the form corresponding to second action is not updated.
But if you forward from one action to another, the request object
still retains the input data, and is applied to the second form. If
your second form has setters and they are compatible name-wize with
input parameters, they will be set.

On the other hand, what you want to do is a clear example of action
chaining which is frowned upon ;-)

Michael.

On 11/14/05, Oleg <ol...@gmail.com> wrote:
> Hi,
>
> I found a long thread talking about one jsp, two action, two action
> forms. However my situation is a bit different and suggested solutions
> would not work, plus I didn't want resurrect an old thread :)
>
> I have:
>
> Jsp A -> Action A (ActionForm A)
>
> Now there are occasions when I need another action, Action B executed
> before Action A but I can only use one jsp page. So what I would have
> is:
>
> Jsp AB - Action B(ActionForm B) ->Action A(ActionForm A)
>
> Where Jsp AB has information to populate both ActionForms A and B.
> Both ActionForms are session scope.
>
> Option 1. Would be to manually populate  ActionForm A in Action B, but
> I would like to avoid that since there will be other possible Actions
> similar to Action B(ActionForm B), so Action C, Action D all ending up
> calling Action A(ActionForm A) and I don't want to change all of them
> every time ActionForm A changes.
>
> Option 2. What if I ActionForm B extends ActionForm A and than it
> becomes something like:
> Jsp AB - Action B(ActionForm B) ->Action A { ...ActionForm A =
> (ActionForm A)ActionForm B..}
>
> This could work but than I am out of luck when I need to use a
> DynaValidatorForm as ActionForm C in  Action C(ActionForm C) - >
> Action A(ActionForm A)
>
> What do you think guys? Whats the best way to go about it.
>
> Thanks,
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Oleg <ol...@gmail.com>.
I read through the documentation and it seems like a nice add-on,
however, I did not see any examples on submitting two action forms
with one jsp page at the same time. Can you show me a code sample?

Thanks
Oleg

On 11/15/05, Oleg <ol...@gmail.com> wrote:
> Cool. I will check it out. Any other ideas on how to do it without
> extra libraries, with just struts?
>
> Thanks,
> Oleg
>
> On 11/15/05, Danny Lee <ha...@yahoo.de> wrote:
> > Yeap I had similar problem too,
> > perfectly solved with Struts Dialogs Framework.
> >
> > Just check this stuff out.
> >
> > http://struts.sourceforge.net/strutsdialogs/
> >
> > Cheers
> >
> > Danny
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Oleg <ol...@gmail.com>.
Cool. I will check it out. Any other ideas on how to do it without
extra libraries, with just struts?

Thanks,
Oleg

On 11/15/05, Danny Lee <ha...@yahoo.de> wrote:
> Yeap I had similar problem too,
> perfectly solved with Struts Dialogs Framework.
>
> Just check this stuff out.
>
> http://struts.sourceforge.net/strutsdialogs/
>
> Cheers
>
> Danny
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Posting from 1JSP to 2Actions and 2Forms

Posted by Danny Lee <ha...@yahoo.de>.
Yeap I had similar problem too,
perfectly solved with Struts Dialogs Framework.

Just check this stuff out.

http://struts.sourceforge.net/strutsdialogs/

Cheers

Danny


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