我有以下工作代码:
<h:outputLabel value="Name:" for="nameField"/>
<h:panelGroup>
<h:inputText id="nameField" value="${bean.name}" required="true" />
<t:message for="nameField"
detailFormat="!" tooltip="true" errorClass="errorMessage"
infoClass="infoMessage" fatalClass="fatalMessage"
warnClass="warningMessage"/>
</h:panelGroup>
现在我正在尝试将消息组件包装成一个如下所示的复合组件:
<composite:interface>
<composite:attribute name="for" required="true"/>
</composite:interface>
<composite:implementation>
<t:message for="#{cc.attrs.for}"
detailFormat="!" tooltip="true"
errorClass="errorMessage" infoClass="infoMessage"
fatalClass="fatalMessage" warnClass="warningMessage"/>
</composite:implementation>
使用参考实现(2.0.3),我得到以下异常:
Jul 8, 2011 10:59:13 AM org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMessageRendererBase renderMessage
SEVERE: Could not render Message. Unable to find component 'nameField' (calling findComponent on component 'simplePersonSearchForm:j_idt89:j_idt100'). If the provided id was correct, wrap the message and its component into an h:panelGroup or h:panelGrid.
java.lang.NullPointerException
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.createMetaRuleset(CompositeComponentTagHandler.java:247)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:123)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:96)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.setAttributes(CompositeComponentTagHandler.java:225)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:178)
.....
.....
答案 0 :(得分:0)
它适用于<h:message>
。我认为这是Tomahawk实施中的一个错误。
所以你有两个选择:
将其替换为<h:message>
。
向Tomahawk家伙报告此问题并等待他们修复。