开发者

JSF 2 h:message in composite component can't find id of input

I have the following working code:

<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>

Now I'm trying to wrap the message component into a composite component that looks like this:

<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>

With the reference implementation (2.0.3) I get the following exception:

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)
.....
.....


It works fine with <h:message>. I'd consider it to be a bug in Tomahawk's implementation.

So you have 2 options:

  1. Replace it with <h:message>.

  2. Report the issue to Tomahawk guys and wait for them to get it fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜