[
https://issues.apache.org/jira/browse/WW-5117?focusedWorklogId=708507&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-708507
]
ASF GitHub Bot logged work on WW-5117:
--------------------------------------
Author: ASF GitHub Bot
Created on: 13/Jan/22 17:04
Start Date: 13/Jan/22 17:04
Worklog Time Spent: 10m
Work Description: lukaszlenart commented on a change in pull request #525:
URL: https://github.com/apache/struts/pull/525#discussion_r784154612
##########
File path: core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
##########
@@ -346,7 +346,7 @@ public void testSimple_recursionTest() throws Exception {
tag.setName("myname");
tag.setValue("%{foo}");
tag.setSize("10");
- tag.setDynamicAttribute(null, "anotherAttr", "%{foo}");
+ tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}");
Review comment:
I can revert this change, but Dynamic Attributes are quite often used in
such way `static_text_%{variable}` and if you check the
`dynamic-attributes.ftl` file you will notice that it uses
`TextParseUtil.translateVariables()` - the same I have used here in UIBean -
`TextParseUtil.translateVariables('%', attrValue, stack);`.This doesn't
eliminate monitor of double evaluation.
It had been happening because the same attributes had been evaluated in
[Component](https://github.com/apache/struts/commit/8bbe1949e17d58e1b5aef9c71e1279ad12ad7ba7#diff-0a39f082871f48bd14037ab2e3a3911b0b1046506c1d93338024d77d412a7075L305-L309)
and then again in `dynamic-attributes.ftl`. My change (which is exactly the
same as for Struts 2.5.x) just performs this evaluation just once - either in
`UIBean` (if `lazyEvaluation` is `false`) or in `dynamic-attributes.ftl` (once
`lazyEvaluation` is set to `true`).
This was the origin of double evaluation in Dynamic Attributes - evaluation
in `Component` and again in `dynamic-attributes.ftl`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 708507)
Time Spent: 6h 50m (was: 6h 40m)
> %{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
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 2.5.29, 2.6
>
> Time Spent: 6h 50m
> Remaining Estimate: 0h
>
> {{%\{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.20.1#820001)