views:

13

answers:

0

The default stack has the parms interceptor who binds the parameters to the setters found in the action who is being invoked. That works fine when you know the name of the parameter. For example if a request parameter is "employee.name" that could be binded to a property of my action which has a property "employee" with a property "name". In order to get it to work I need to know which name the request parameter name would be and put a setter in my action called setEmployee() of an object type Employee or it could be a Map too.

What if I want to let the action bind that param to another property that I don't know which one will be. Let's say that the action receive as a parameter the name on which the request parameter will be set.

<s:action name="showEmployee" executeResult="true">
   <s:param name="employeePrefix">xyz.wz.empl</s:param>
</s:action>

That would mean to the action to bind all the parameters of the employee to xyz.wz.empl. For example let's say the request parameter has the following: xyz.wz.empl.name=Alfredo xyz.wz.empl.lastName=Osorio

I would like to bind that to a property of my action, let's say a Map employee, but that won't work because the request parameter is xyz.wz.empl. How can I bind that dynamic parameter to the invoked action using the parameter that was sent to the action (employeePrefix).

I could ask for the request parameters

ActionContext.getContext().getParameters()

and do the conversion myself but I think there must be another way to explicitly call something from the Struts 2 framework to the conversion, in the way that com.opensymphony.xwork2.interceptor.ParametersInterceptor does.

Thank You.