Permalink
Browse files

Experimental commit for tag that shields facelet tag from its parent's

parameters
  • Loading branch information...
arjantijms committed Jan 7, 2015
1 parent 7102035 commit 0cd13ea5c76e32fb8806a8a131e69fe5a6073a78
@@ -0,0 +1,41 @@
package org.omnifaces.taghandler;
import java.io.IOException;
import javax.el.ValueExpression;
import javax.el.VariableMapper;
import javax.faces.component.UIComponent;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.TagAttribute;
import javax.faces.view.facelets.TagConfig;
import javax.faces.view.facelets.TagHandler;
public class TagParameter extends TagHandler {
private final TagAttribute name;
public TagParameter(TagConfig config) {
super(config);
name = getRequiredAttribute("name");
}
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
String nameStr = name.getValue(ctx);
VariableMapper variableMapper = ctx.getVariableMapper();
ValueExpression valueExpressionLocal = variableMapper.setVariable(nameStr, null);
if (valueExpressionLocal == null) {
ValueExpression valueExpressionParent = variableMapper.resolveVariable(nameStr);
if (valueExpressionParent != null) {
valueExpressionLocal = ctx.getExpressionFactory().createValueExpression(null, Object.class);
}
}
variableMapper.setVariable(nameStr, valueExpressionLocal);
}
}
@@ -2165,6 +2165,27 @@ public class ValidateValuesBean implements MultiFieldValidator {
<type>java.lang.String</type>
</attribute>
</tag>
<tag>
<description>
<![CDATA[
Experimental tag to shield Facelets tags from attributes set on parent tags
]]>
</description>
<tag-name>tagParameter</tag-name>
<handler-class>org.omnifaces.taghandler.TagParameter</handler-class>
<attribute>
<description>
<![CDATA[
]]>
</description>
<name>name</name>
<required>true</required>
<type>java.lang.String</type>
</attribute>
</tag>
<tag>
<description>

0 comments on commit 0cd13ea

Please sign in to comment.