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:27 UTC
[struts] 02/04: WW-5117 Evaluates dynamic attributes when assigning them to tag Reverts https://github.com/apache/struts/pull/447/commits/8bbe1949e17d58e1b5aef9c71e1279ad12ad7ba7#diff-0a39f082871f48bd14037ab2e3a3911b0b1046506c1d93338024d77d412a7075L305-L309
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 893a8924eb7b9723df3797bb5060847df61f2094
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Tue Jan 4 20:21:28 2022 +0100
WW-5117 Evaluates dynamic attributes when assigning them to tag
Reverts https://github.com/apache/struts/pull/447/commits/8bbe1949e17d58e1b5aef9c71e1279ad12ad7ba7#diff-0a39f082871f48bd14037ab2e3a3911b0b1046506c1d93338024d77d412a7075L305-L309
---
.../main/java/org/apache/struts2/components/UIBean.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 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 24b47fa..9ec23d5 100644
--- a/core/src/main/java/org/apache/struts2/components/UIBean.java
+++ b/core/src/main/java/org/apache/struts2/components/UIBean.java
@@ -21,6 +21,7 @@ package org.apache.struts2.components;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -30,7 +31,7 @@ import org.apache.struts2.components.template.Template;
import org.apache.struts2.components.template.TemplateEngine;
import org.apache.struts2.components.template.TemplateEngineManager;
import org.apache.struts2.components.template.TemplateRenderingContext;
-import org.apache.struts2.dispatcher.StaticContentLoader;
+import org.apache.struts2.util.ComponentUtils;
import org.apache.struts2.util.TextProviderHelper;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.util.ContextUtil;
@@ -1272,10 +1273,15 @@ public abstract class UIBean extends Component {
public void setDynamicAttributes(Map<String, String> tagDynamicAttributes) {
for (Map.Entry<String, String> entry : tagDynamicAttributes.entrySet()) {
- String entryKey = entry.getKey();
+ String attrName = entry.getKey();
+ String attrValue = entry.getValue();
- if (!isValidTagAttribute(entryKey)) {
- dynamicAttributes.put(entryKey, entry.getValue());
+ if (!isValidTagAttribute(attrName)) {
+ if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.isExpression(attrValue)) {
+ dynamicAttributes.put(attrName, String.valueOf(ObjectUtils.defaultIfNull(findString(attrValue), attrValue)));
+ } else {
+ dynamicAttributes.put(attrName, attrValue);
+ }
}
}
}