You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ha...@informatiefabriek.nl on 2003/04/24 13:44:29 UTC

basic form submit question

Hi all,

I have a form containing some textfields and radio buttons.
The user should fill in some questions and then submit the form using a 
submit button.
The submit calls my action class, which processes the values filled in by 
the user and forwards the user to another page.

But the user should also be able to submit the same form to an other 
action. How can I achieve this. 
I need the values filled in by the user in the jsp page in both actions. 

Is there a possibillity to submit a form to multiple/different actions?

If not, how should I approach this problem?

Thanks,

Harm de Laat
Informatiefabriek


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


Re: basic form submit question

Posted by James Mitchell <jm...@apache.org>.
What is your criteria for submitting to one action versus the other?

If you know ahead of time (from the preceding action) which action the jsp
will submit to, then just handle it like two separate actions (that happen
to use the same form).

If you need to do this from the jsp page (and you don't know ahead of time),
you could get around having to use JavaScript by taking advantage of
DispatchAction.  Whether the decision is made (on the page) by radio buttons
or a select list, if you specify the name as "method", and value as what is
needed by your DispatchAction, Struts will do the rest.

HTH

--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: <ha...@informatiefabriek.nl>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, April 24, 2003 7:54 AM
Subject: Re: basic form submit question


> Yes, I mean from the same page....
>
> It should be possible to submit my form to two different actions.
>
> * The first action stores the values filled in by the user in the Session
> object. Then forward the user to a page to upload files (sort of like
> attachments).
>   Then it writes the values filled in by the user into a database.
>
> * The second action does not present the user a page to upload files. But,
> directly writes the values filled in by the user to the database.
>
> I could use javascript to alter the action target. But, maybe there is a
> more common way to achieve this using only the struts framework?
>
> Thanks,
>
> Harm.
>
>
>
>
> "James Mitchell" <jm...@apache.org>
> 04/24/2003 01:47 PM
> Please respond to
> "Struts Users Mailing List" <st...@jakarta.apache.org>
>
>
> To
> "Struts Users Mailing List" <st...@jakarta.apache.org>
> cc
>
> Subject
> Re: basic form submit question
>
>
>
>
>
>
> Yes, just setup 2 different actions and have them use the same formbean.
>
> Getting the form to submit to a different action will be a little tricky
> (if
> you mean doing it from the same page).  You'll need to change the target
> with a bit of JavaScript.
>
> --
> James Mitchell
> Software Developer/Struts Evangelist
> http://www.open-tools.org
>
>
>
> ----- Original Message -----
> From: <ha...@informatiefabriek.nl>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, April 24, 2003 7:44 AM
> Subject: basic form submit question
>
>
> > Hi all,
> >
> > I have a form containing some textfields and radio buttons.
> > The user should fill in some questions and then submit the form using a
> > submit button.
> > The submit calls my action class, which processes the values filled in
> by
> > the user and forwards the user to another page.
> >
> > But the user should also be able to submit the same form to an other
> > action. How can I achieve this.
> > I need the values filled in by the user in the jsp page in both actions.
> >
> > Is there a possibillity to submit a form to multiple/different actions?
> >
> > If not, how should I approach this problem?
> >
> > Thanks,
> >
> > Harm de Laat
> > Informatiefabriek
> >
> >
> > ---------------------------------------------------------------------
> > 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


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


Re: basic form submit question

Posted by ha...@informatiefabriek.nl.
Yes, I mean from the same page....

It should be possible to submit my form to two different actions. 

* The first action stores the values filled in by the user in the Session 
object. Then forward the user to a page to upload files (sort of like 
attachments).
  Then it writes the values filled in by the user into a database.

* The second action does not present the user a page to upload files. But, 
directly writes the values filled in by the user to the database.

I could use javascript to alter the action target. But, maybe there is a 
more common way to achieve this using only the struts framework?

Thanks,

Harm.




"James Mitchell" <jm...@apache.org> 
04/24/2003 01:47 PM
Please respond to
"Struts Users Mailing List" <st...@jakarta.apache.org>


To
"Struts Users Mailing List" <st...@jakarta.apache.org>
cc

Subject
Re: basic form submit question






Yes, just setup 2 different actions and have them use the same formbean.

Getting the form to submit to a different action will be a little tricky 
(if
you mean doing it from the same page).  You'll need to change the target
with a bit of JavaScript.

--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: <ha...@informatiefabriek.nl>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 24, 2003 7:44 AM
Subject: basic form submit question


> Hi all,
>
> I have a form containing some textfields and radio buttons.
> The user should fill in some questions and then submit the form using a
> submit button.
> The submit calls my action class, which processes the values filled in 
by
> the user and forwards the user to another page.
>
> But the user should also be able to submit the same form to an other
> action. How can I achieve this.
> I need the values filled in by the user in the jsp page in both actions.
>
> Is there a possibillity to submit a form to multiple/different actions?
>
> If not, how should I approach this problem?
>
> Thanks,
>
> Harm de Laat
> Informatiefabriek
>
>
> ---------------------------------------------------------------------
> 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: basic form submit question

Posted by James Mitchell <jm...@apache.org>.
Yes, just setup 2 different actions and have them use the same formbean.

Getting the form to submit to a different action will be a little tricky (if
you mean doing it from the same page).  You'll need to change the target
with a bit of JavaScript.

--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: <ha...@informatiefabriek.nl>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 24, 2003 7:44 AM
Subject: basic form submit question


> Hi all,
>
> I have a form containing some textfields and radio buttons.
> The user should fill in some questions and then submit the form using a
> submit button.
> The submit calls my action class, which processes the values filled in by
> the user and forwards the user to another page.
>
> But the user should also be able to submit the same form to an other
> action. How can I achieve this.
> I need the values filled in by the user in the jsp page in both actions.
>
> Is there a possibillity to submit a form to multiple/different actions?
>
> If not, how should I approach this problem?
>
> Thanks,
>
> Harm de Laat
> Informatiefabriek
>
>
> ---------------------------------------------------------------------
> 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