Well, as the others said DispatchAction is the way to
go.

Since, you already have two separate Actions defined,
I thought it may be worthwhile to give my idea a try.

What I meant was, instead of a "submit" button
<html:submit>, use a normal button <input
type="button">. You can display a "create" or "update"
button based on the previous screen, i.e.

<logic:equal name="formName" property="whichAction"
value ="create">
<input type="button" name="Create"
onClick="submitForm" >
</logic:equal>

<logic:equal name="formName" property="whichAction"
value ="update">
<input type="button" name="Update"
onClick="submitForm" >
</logic:equal>

Then, in your submitForm() Javascript, check for which
button is clicked, or check for whichAction as you're
doin now, and set the action accordingly. (Sorry, I'm
not an expert in Javascript!)

HTH,
Shyam


--- "Au-Yeung, Stella H" <[EMAIL PROTECTED]>
wrote:
> Shyam:
> I am not sure what you mean, can you elaborate that?
> The current form only has one 'submit' button. 
> After the user fills in data
> on the current form, I want the data to be submitted
> to the DB and then
> automatically be taken back to the 'previous'
> screen.  This previous screen
> can be a 'Create main screen' or an 'Update main
> screen'.   I use a hidden
> field 'whichAction' to "remember" which is the
> 'previous' screen.   So when
> the user submits the input data on the cuurrent
> form, that's when the
> javascript submitForm() function decides which
> screen
> (/app/fdd/shopWorkOrder/fromCreateShopWorkOrder or
> /app/fdd/shopWorkOrder/fromUpdateShopWorkOrder) to
> return to.
> 
> Example:
> 
> Create Main screen  ---->  use 'theForm' to input
> data  -------->  return
> back to Create main
> 
> Update Main screen  -----> use 'theForm' to input
> data  -------->  return
> back to Update main
>         
>                          (this screen 'theForm' is
> where I decide
>                           which precious screen to
> return
>                           to based on the hidden
> field "whichAction".
>                           That's why <form action>
> has to be dynamic
> 
> My user only wants "ONE" submit button on "theForm"
> and the application
> should be smart enough to return to the correct
> 'previous' page.
>                                         
> 
> 
> 
> -----Original Message-----
> From: Shyam A [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 23, 2004 5:31 PM
> To: Struts Users Mailing List
> Subject: RE: Must have action="....." in <html:form>
> tag?
> 
> 
> Just a suggestion. Not sure if I'm right...
> Instead of using onSubmit() event of your
> <html:form>,
> why don't you call the Javascript when the user
> clicks/submits the associcated HTML component -
> "Create/Update button", and set the action
> accordingly.
> 
> HTH,
> Shyam
> 
> 

__________________________________
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]

Reply via email to