Struts places mapping name in the request before redirecting to the JSP
We extended FormTag and allows action not to be mandatory. If no action
is defined in the tag, we have the following code to get action name:

ActionMapping mapping =
(ActionMapping)pageContext.getRequest().getAttribute(Action.MAPPING_KEY)
;
if (mapping != null) {
        value = mapping.getPath();
        if (value != null)
                value = value.substring(1);
}
action = value;

Besides, we use DispatchAction and our FormTag creates the hidden
property needed to perform dispatch introspection, for example, if you
define parameter="dispatch", a <input tyoe="hidden" name="dispatch"> tag
will automatically be created by FormTag.

We use "self-detecting" mapping name to "reuse" the same JSP in
different ActionMappings, and use DispatchAction to determine, for
example, if we have to perform a save or an update. We have a dispatch
method name called "store", witch determines if user is updating or
creating (with a mark set in request or session) and calls itself to
"save" or "update". From JSP view, you always call store.

Cheers.
Guillermo.

-----Original Message-----
From: Au-Yeung, Stella H [mailto:[EMAIL PROTECTED] 
Sent: Martes, 24 de Febrero de 2004 02:51 a.m.
To: 'Struts Users Mailing List'
Subject: RE: Must have action="....." in <html:form> tag?


I understand DispatchAction fairly well.   But because there are certain
extra things I need to do that DispatchAction won't help.   Anyway,
Shyam's
suggestion of using <logic:equal> to display the appropriate button with
associate action should take care of my problem and I think it will be
pretty simple.  Thanks Shyam.

I would also like to thank everyone who has responded to my plead for
help (Geeta, Paul, Hubert,Ramadoss and Khalid etc.)  Thanks you all.

-----Original Message-----
From: Shyam A [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 23, 2004 6:34 PM
To: Struts Users Mailing List
Subject: RE: Must have action="....." in <html:form> tag?


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]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido exclusivamente a las 
personas direccionadas en el mail y puede contener informacion (i)de propiedad 
exclusiva de Interbanking S.A. o (ii) amparada por el secreto profesional. Cualquier 
opinion en el contenido, es exclusiva de su autor y no representa necesariamente la 
opinion de Interbanking S.A. El acceso no autorizado, uso, reproduccion, o divulgacion 
esta prohibido. Interbanking S.A no asumira responsabilidad ni obligacion legal alguna 
por cualquier informacion incorrecta o alterada contenida en este mensaje. Si usted ha 
recibido este mensaje por error, le rogamos tenga la amabilidad de destruirlo 
inmediatamente junto con todas las copias del mismo, notificando al remitente. No 
debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni ninguna de sus 
partes si usted no es el destinatario. Muchas gracias.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to