[ 
https://issues.apache.org/jira/browse/WW-5117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17292556#comment-17292556
 ] 

James Chaplin commented on WW-5117:
-----------------------------------

Hello.

After taking an initial look, I was unable to determine why the behaviour might 
have changed since 2.5.20.  Since both the hidden tag component and action in 
this scenario have an "id" property, maybe the order or precedence of 
processing changed in some way ?

There might be another workaround that does not involve introducing a var 
alias/copy:
{noformat}
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:hidden name="first" data-first="%{#action.getId()}" id="firstId" 
value="%{id}"/>
<s:hidden name="second" data-second="%{#action.getId()}" id="secondId" 
value="%{id}"/>
{noformat}
It seemed to work for me, but my local example might not match the reported 
scenario exactly.

Since the "id" property name-clashes, if there is a way to avoid the name-clash 
(with the s:set var workaround, or an alias getter in the action), that might 
be a "safer" choice for an implementation.

> %{id} evaluates different for data-* and value attribute
> --------------------------------------------------------
>
>                 Key: WW-5117
>                 URL: https://issues.apache.org/jira/browse/WW-5117
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.5.26
>            Reporter: Jonas Marczona
>            Priority: Major
>             Fix For: 2.5.27
>
>
> {{%\{id\}}} evaluates for "data-*" attributes in a different way than for the 
> "value" attribute. 
> in a very simple context where I have only one getter:
> {code}
> public Long getId() {
>    return 27357L;
> }
> {code}
> The following two usages of "id" in one tag in a jsp evaluates in different 
> ways:
> JSP:
> {noformat}
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <s:hidden name="first" data-wuffmiauww="%{id}" id="einszwei" value="%{id}"/>
> <s:hidden name="second" data-wuffmiauww="%{id}" value="%{id}"/>
> {noformat}
> Result:
> {noformat}
> <input type="hidden" name="first" value="27357" id="einszwei" 
> data-wuffmiauww="einszwei">
> <input type="hidden" name="second" value="27357" data-wuffmiauww>
> {noformat}
> I expect the Id of my getter - for both cases. 
> The value for {{data-wuffmiauww}} is wrong.
> With struts2 version 2.5.20 the result was correct:
> {noformat}
> <input type="hidden" name="first" value="27357" id="einszwei" 
> data-wuffmiauww="27357">
> <input type="hidden" name="second" value="27357" data-wuffmiauww="27357">
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to