You can't.
Correct me if I'm wrong, but the <html:form action=""> property is what
let's struts know which Form object to map your .jsp to. I'm don't think
this will work for you unless all the possible urls you'd submit to share
the same Form.
What you may want to do instead then is look at something along the lines of
DispatchAction, and pass a parameter that tells Struts which logical action
it should forward to after hitting the for submit action (which would be a
subclass of DispatchAction or something similar).
Of course you could do as the previous poster said and change the action to
submit to in your javascript onSubmit function:
function onSubmit() {
forms[0].action="/Some/New/Action.do";
return true;
}
And then you'd put logic to decide where to actually submit to inside the
onSubmit function.
-----Original Message-----
From: Au-Yeung, Stella H [mailto:[EMAIL PROTECTED]
Sent: Monday, February 23, 2004 4:13 PM
To: 'Struts Users Mailing List'
Subject: RE: Must have action="....." in <html:form> tag?
But I don't always want "/app/fdd/shopWorkOrder/fromCreateShopWorkOrder" to
be my action all the time. I want the action for the form to be "dynamic"
and depends on the form field "whichAction". That's why I created the
javascript function submitForm(frm) to pick the action "dynamically". In
other words, I have <action mapping> in my struts-config.xml file for both
path "/app/fdd/shopWorkOrder/fromCreateShopWorkOrder" and
"/app/fdd/shopWorkOrder/fromUpdateShopWorkOrder". But I want whichever one
to be chosen to be "dynamically". So how I do that all within the
<html:form> tag?
-----Original Message-----
From: Hubert Rabago [mailto:[EMAIL PROTECTED]
Sent: Monday, February 23, 2004 4:58 PM
To: Struts Users Mailing List
Subject: RE: Must have action="....." in <html:form> tag?
I never said anything close to what you're asking me.
All I said is choose one of your two possible outcomes (doesn't matter which
one), take the path that you gave it in the struts-config.xml, then use that
in your <html:form>.
Let's say you have the ff entry in your struts-config:
<action path="/fromCreateShopWorkOrder" ...
name="theForm">
<forward .../>
</action>
then in your html:form, specify that action:
<html:form action="/fromCreateShopWorkOrder"
method="post"
onSubmit="return submitForm(document.theForm)">
...
</html:form>
You do have <action>'s associated with fromCreateShopWorkOrder and
fromUpdateShopWorkOrder, right?
- Hubert
--- "Au-Yeung, Stella H" <[EMAIL PROTECTED]> wrote:
> Hubert:
> Can you elaborate that.... In othe words, how do I do everything that
> the function submitForm() does to dynamically pick an action all
> within the <html:form> tag?
>
> -----Original Message-----
> From: Hubert Rabago [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 23, 2004 4:36 PM
> To: Struts Users Mailing List
> Subject: Re: Must have action="....." in <html:form> tag?
>
>
> Specify the Action associated with "fromCreateShopWorkOrder" or
> "fromUpdateShopWorkOrder" in the <html:form> attribute.
>
> --- "Au-Yeung, Stella H" <[EMAIL PROTECTED]> wrote:
> > Hi:
> > My <html:form> tag doesn't allow me to skip an 'action' attribue. If
> you
> > look at my code below, I move the assignment of the 'form action'
> > to
> > the javascript function so which action to take is dynamically depends
> > on the form element 'whichAction'. But the compiler insist I have to
> > have the 'action' property right inside the <html:form> tag. But that
> doesn't allow
> > me to choose the action dynamically. Does anyone have any suggestion?
> >
> > <script language = "Javascript">
> > function submitForm(frm)
> > {
> > var whichAction=frm.elements("whichAction")
> >
> > if (whichAction == "create")
> > {
> > document.theForm.action =
> > "/app/fdd/shopWorkOrder/fromCreateShopWorkOrder;
> > }
> > else
> > {
> > document.theForm.action =
> > "/app/fdd/shopWorkOrder/fromUpdateShopWorkOrder;
> > }
> >
> > return true;
> > }
> > </script>
> >
> >
> > <jsp:useBean id="ShopWorkOrderBean" scope="request"
> >
> > class="com.cat.sdl.fdd.formBean.shopWorkOrder.ShopWorkOrderForm"/>
> > <html:form name="theForm" method="post" onSubmit="return
> > submitForm(document.theForm)">
> >
> >
> > I got the following error with the above code:
> > Parsing of JSP File '/app/fdd/shopWorkOrder/CreateTLFPart.jsp'
> > failed:
> > /app/fdd/shopWorkOrder/CreateTLFPart.jsp(28): required attribute
'action'
> > not specified for tag 'form'
> > probably occurred due to an error in
> > /app/fdd/shopWorkOrder/CreateTLFPart.jsp line 28: <html:form
> > name="theForm" method="post" onSubmit="return
> > submitForm(document.theForm)">
> >
> >
> >
> >
> > --------------------------------------------------------------------
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail SpamGuard - Read only the mail you want.
> http://antispam.yahoo.com/tools
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]