You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2022/01/13 09:25:29 UTC
[struts] 04/04: WW-5117 Uses translateVariables instead of findString to allow join expressions
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch WW-5117-evaluate-dynamic-attributes-cherrypick
in repository https://gitbox.apache.org/repos/asf/struts.git
commit b0e18e9c577d1f8c6c1417a054a11c52cd624234
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Thu Jan 6 09:03:07 2022 +0100
WW-5117 Uses translateVariables instead of findString to allow join expressions
---
core/src/main/java/org/apache/struts2/components/UIBean.java | 4 +++-
core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java
index a9b8f50..e010ead 100644
--- a/core/src/main/java/org/apache/struts2/components/UIBean.java
+++ b/core/src/main/java/org/apache/struts2/components/UIBean.java
@@ -20,6 +20,7 @@ package org.apache.struts2.components;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@@ -1278,7 +1279,8 @@ public abstract class UIBean extends Component {
if (!isValidTagAttribute(attrName)) {
if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.containsExpression(attrValue) && !lazyEvaluation()) {
- dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(findString(attrValue), attrValue));
+ String translated = TextParseUtil.translateVariables('%', attrValue, stack);
+ dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(translated, attrValue));
} else {
dynamicAttributes.put(attrName, attrValue);
}
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
index cf300e8..56d0eaa 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
@@ -372,7 +372,7 @@ public class TextfieldTest extends AbstractUITagTest {
tag.setName("myname");
tag.setValue("%{foo}");
tag.setSize("10");
- tag.setDynamicAttribute(null, "anotherAttr", "%{foo}");
+ tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}");
tag.doStartTag();
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).