[ 
https://issues.apache.org/jira/browse/WW-3730?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lukasz Lenart updated WW-3730:
------------------------------

    Fix Version/s: 2.5

Possible change can break backward compatibility
                
> action tag accepts only String arrays as parameters
> ---------------------------------------------------
>
>                 Key: WW-3730
>                 URL: https://issues.apache.org/jira/browse/WW-3730
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.2.3.1, 2.3.1, 2.3.1.1, 2.3.x
>            Reporter: Pavel Kazlou
>             Fix For: 2.5
>
>
> {{org.apache.struts2.components.Component}} accepts arbitrary objects as 
> parameters: 
> {code}
>     public Map getParameters() {
>         return parameters;
>     }
>     ...
>     public void addParameter(String key, Object value) {
>         if (key != null) {
>             Map params = getParameters();
>             if (value == null) {
>                 params.remove(key);
>             } else {
>                 params.put(key, value);
>             }
>         }
>     }
> {code}
> But {{org.apache.struts2.components.ActionComponent}} explicitly casts all 
> his parameters to {{String[]}}:
> {code}
> protected Map<String,String[]> createParametersForContext() {
>         Map parentParams = null;
>         if (!ignoreContextParams) {
>             parentParams = new 
> ActionContext(getStack().getContext()).getParameters();
>         }
>         Map<String,String[]> newParams = (parentParams != null) 
>             ? new HashMap<String,String[]>(parentParams) 
>             : new HashMap<String,String[]>();
>         if (parameters != null) {
>             Map<String,String[]> params = new HashMap<String,String[]>();
>             for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); 
> ) {
>                 Map.Entry entry = (Map.Entry) i.next();
>                 String key = (String) entry.getKey();
>                 Object val = entry.getValue();
>                 if (val.getClass().isArray() && String.class == 
> val.getClass().getComponentType()) {
>                     params.put(key, (String[])val);
>                 } else {
>                     params.put(key, new String[]{val.toString()});
>                 }
>             }
>             newParams.putAll(params);
>         }
>         return newParams;
>     }
> {code}
> So I can't pass arbitrary objects directly to action using syntax:
> {code}
> <s:action name="myAction"><s:param name="customObject" 
> value="customObject"/></s:action>
> {code}
> without conversion customObject->String->customObject.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to