The "parameter" attribute can have whatever value you want and be used
however you want. I use it as a poor man's dispatch action.
For example, you have an actor called a "customer". The customer can log
on and perform some actions with regard to his details. Let's say one
action is to view, another is to edit. Since much of the logic could be
shared between these two actions, you might want to use the same Struts
Action class and ActionForm class to handle both actions.
So you might have two mappings that use the same Action, say,
"/customer/viewDetails" and "/customer/editDetails". They are both
mapped to the same name (ActionForm) and type (Action), but you can use
parameter to distinguish, by setting it to "view" in one mapping and
"edit" in the other. Your execute method can now switch on
mapping.getParameter.
Since (as far as I know) the value can be whatever you want, you could
probably come up with other ways to use it as well.
Erik
K Rajesh wrote:
i have done only one struts application. but the below action tag, i
can't understand......... could you anybody give me some code to let
me know about the parameter="show" attribute
Rj
On 3/9/05, Nicolas De Loof <[EMAIL PROTECTED]> wrote:
Each mapping have to define a parameter that sets the internal method to
be used
You can use parameter as the method name :
<action path="/showEmployeeDetail"
name="EmployeeForm"
scope="request"
validate="false"
type="com.mycompany.EmployeeAction"
parameter="show">
and in execute() :
if ("show".equals(getParameter))
return show(mapping, form...)
else if ("update".equals(getParameter))
return update(mapping, form...)
else
return mapping.findForward("error");
Another way is to set parameter to the name of a request param that will
define the method to be used. Doing this, you have to add this parameter
to your request (using an hidden input). Doing this, you only need one
mapping as you can change validation behaviour according to this
attribute value.
<action path="/EmployeeDetail"
name="EmployeeForm"
scope="request"
validate="false"
type="com.mycompany.EmployeeAction"
parameter="action">
in form-bean validate() :
String param = mapping.getParameter();
String action = request.getParameter(param)
if ("show".equals(action))
// check employeId is set
else if ("update".equals(action))
// check employee datas
Nico.
Gaet a écrit :
Thanks nicolas,
I know the dispatch action but I don't see how to use it with 2 mappings:
how the mappings "/showEmployeeDetail" and "/updateEmployeeDetail" will know
the method to execute in my dispatch action?
Thank you very much!
----- Original Message -----
From: "Nicolas De Loof" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Wednesday, March 09, 2005 5:09 PM
Subject: Re: Design problem
You should define 2 mappings for detail :
a "/showEmployeeDetail" without validation (or a unique rule employeeId
required)
a "/updateEmployeeDetail" with validation.
Your action can be a dispatch action if you don't want to have 2 classes.
Nico.
Gaet a écrit :
Hi,
I have page with a list of employees.
On that list, if you click on an employee name, I want to redirect to an
edit page...easy no?
but how to define the complete process into struts-config? Below you will
find my actual struts-config but here is my problem :
I have defined the /EmployeeDetail action-mapping with validate equal to
false to be able to display the employee detail page without any
check....but if the user made any changes on the employee information in
the
detailled page, the same action is called and then i need to validate my
form! Maybe my configuration is not good....
<action path="/initEmployeeList"
type="com.ajo.InitEmployeeAction"
name="EmployeeForm"
validate="false"
parameter="reqCode"
scope="session">
<forward name="continue" path="/EmployeeListe.jsp"/>
<forward name="create" path="EmployeeDetail.do"/>
<forward name="update" path="EmployeeDetail.do"/>
</action>
<action path="/EmployeeDetail"
type="org.ajo.EmployeeAction"
name="EmployeeForm"
validate="false"
scope="request">
<forward name="continue" path="/EmployeeDetail.jsp"/>
</action>
in EmployeeDetail.jsp, I have the following form definition :
<html:form action="/EmployeeDetail">...
Thanks for your help
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is intended only for the
person to whom it is addressed. If you are not the intended recipient, you
are not authorized to read, print, retain, copy, disseminate, distribute,
or use this message or any part thereof. If you receive this message in
error, please notify the sender immediately and delete all copies of this
message.
---------------------------------------------------------------------
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]
This message contains information that may be privileged or confidential and is
the property of the Capgemini Group. It is intended only for the person to whom
it is addressed. If you are not the intended recipient, you are not authorized
to read, print, retain, copy, disseminate, distribute, or use this message or
any part thereof. If you receive this message in error, please notify the
sender immediately and delete all copies of this message.
---------------------------------------------------------------------
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]