具有可选id属性的Facelet标记

时间:2016-07-28 14:03:21

标签: jsf attributes tags facelets

我一直在尝试构建一个Facelet标签(标记为输入)。它工作正常,我试图将id转换为条件属性。有没有办法实现这个目标?我正在使用(PrimeFaces),而我正在尝试做的事情就像:

<h:inputText>
    <c:if test="#{id ne null}">
        <f:attribute name="id" value="#{id}" />
    </c:if>
</h:inputText>

这就是我期望使用它的方式:

<my:outputPanel />

<my:outputPanel id="foo" />

当我尝试使用它时,我收到了这个错误:

java.lang.IllegalArgumentException
at javax.faces.component.UIComponent.setValueExpression(UIComponent.java:484)
at com.sun.faces.facelets.tag.jsf.core.AttributeHandler.apply(AttributeHandler.java:119)
at com.sun.faces.facelets.tag.jstl.core.IfHandler.apply(IfHandler.java:96)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)

这适用于除id之外的属性。它似乎是一种关于id属性的限制。提前感谢您的任何指示。

1 个答案:

答案 0 :(得分:0)

嗯......我曾经在Mojarra 2.0.3中使用属性有相同的异常:SI不是百分百肯定但是它似乎有些保留字或类似:S

作为一种变通方法,您可以尝试直接使用id_属性名称代替id;

祝你好运

相关问题