struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas De Loof <nicolas.del...@capgemini.com>
Subject Re: Design problem
Date Wed, 09 Mar 2005 16:56:10 GMT

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" <nicolas.deloof@capgemini.com>
>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: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>      
>>>
>>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: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message