[
https://issues.apache.org/jira/browse/WW-3226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114534#comment-18114534
]
Lukasz Lenart commented on WW-3226:
-----------------------------------
Triaged against {{main}} (7.4.0-SNAPSHOT).
The requested behaviour is already available through interceptor ordering, so
no new flag is needed. {{AliasInterceptor}} sets the aliased property on the
action at the moment it runs, and so does {{params}}; whichever runs last wins.
Verified with a reproduction against {{SimpleAction}}, request
{{aliasSource=from-source&aliasDest=direct}}, aliases {{#{ 'aliasSource' :
'aliasDest' }}}:
With {{alias}} before {{params}} (the {{defaultStack}} order), {{aliasDest}}
ends as {{direct}} — the directly submitted parameter wins, which is the
surprise reported here.
With {{params}} before {{alias}}, {{aliasDest}} ends as {{from-source}} — the
alias overrides the submitted parameter, which is what an {{overwrite}} flag
would do.
The gap was documentation: the Alias Interceptor page never mentioned this
interaction, and its example places {{alias}} before {{basicStack}}. Fixed in
https://github.com/apache/struts-site/pull/329 with an "Ordering relative to
the {{params}} interceptor" section and a {{params}} → {{alias}} →
{{conversionError}} stack example.
Folding aliases into {{ParametersInterceptor}} would be a redesign of a rarely
used interceptor; if that is ever wanted it should be a fresh ticket against
the current {{@StrutsParameter}}-gated implementation. Closing as Won't Fix.
> Add optional support to AliasInterceptor to overwrite aliased parameters
> ------------------------------------------------------------------------
>
> Key: WW-3226
> URL: https://issues.apache.org/jira/browse/WW-3226
> Project: Struts 2
> Issue Type: Improvement
> Components: Core Interceptors
> Affects Versions: 2.1.8
> Reporter: Jasper Rosenberg
> Priority: Minor
> Fix For: 7.4.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> It would be great if the AliasInterceptor could overwrite the aliased
> parameters rather than just inject them under different names, much like I
> recall staticParams supports. I suspect many, like me, were surprised to
> learn this wasn't how it currently behaved. It would have to be a new flag
> to maintain backwards compatibility.
> Alternatively, the ParametersInterceptor could be enhanced to take an
> optional aliases map. That would be pretty handy.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)