mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
WW-4165 Checks if dynamic attributes don't overlap tag attributes
This can be done only in a component as when dynamic attributes are set by a container on the tag, the component wasn't instantiated yet - it will be created in doStartTag method which is called after all attributes were set
This commit is contained in:
@@ -39,16 +39,10 @@ import org.apache.struts2.views.util.ContextUtil;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* UIBean is the standard superclass of all Struts UI components.
|
||||
@@ -1260,8 +1254,12 @@ public abstract class UIBean extends Component {
|
||||
this.tooltipIconPath = tooltipIconPath;
|
||||
}
|
||||
|
||||
public void setDynamicAttributes(Map<String, Object> dynamicAttributes) {
|
||||
this.dynamicAttributes.putAll(dynamicAttributes);
|
||||
public void setDynamicAttributes(Map<String, Object> tagDynamicAttributes) {
|
||||
for (String key : tagDynamicAttributes.keySet()) {
|
||||
if (!isValidTagAttribute(key)) {
|
||||
dynamicAttributes.put(key, tagDynamicAttributes.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -305,10 +305,6 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
|
||||
}
|
||||
|
||||
public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {
|
||||
if (component.isValidTagAttribute(localName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.isExpression(value)) {
|
||||
dynamicAttributes.put(localName, String.valueOf(ObjectUtils.defaultIfNull(findValue(value.toString()), value)));
|
||||
} else {
|
||||
|
||||
@@ -89,9 +89,9 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
private AnchorTag createTag() throws JspException {
|
||||
AnchorTag tag = new AnchorTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
|
||||
tag.setId("mylink");
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -120,9 +120,10 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
FormTag tag = new FormTag();
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
tag.doStartTag();
|
||||
tag.setDynamicAttribute("uri://some.uri", "includeContext", false);
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
assertTrue(tag.includeContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,6 @@ public class RadioTest extends AbstractUITagTest {
|
||||
|
||||
RadioTag tag = new RadioTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("");
|
||||
|
||||
Reference in New Issue
Block a user