JSF Composite Component:无法使用EL表达式解析使用页面的复合组件

时间:2016-02-29 13:39:22

标签: ajax jsf jsf-2 el composite-component

我在stackoverflow上研究了一些类似的问题,但它们似乎都没有解决我的问题......

我写了一个(简单的)复合组件:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>

    <composite:attribute name="buttonValue" />
    <composite:attribute name="ajaxExecute" />
    <composite:attribute name="ajaxRender" />
    <composite:attribute name="ajaxListener" />

</composite:interface>


<composite:implementation>

    <h:commandButton value="#{cc.attrs.buttonValue}">
        <f:ajax execute="#{cc.attrs.ajaxExecute}"
            render="#{cc.attrs.ajaxRender}" listener="#{cc.attrs.ajaxListener}" />
    </h:commandButton>

</composite:implementation>

</html>

并将这个包含在我的视图中:

<my:ajaxCommandButton
                buttonValue="foo"
                ajaxExecute=""
                ajaxRender=""
                ajaxListener="#{viewBacking.resend()}"></my:ajaxCommandButton>

有趣的是 - 这家伙的工作方式就像一个冠军(!) - 每次点击它时,bean方法都会被调用,而且一切看起来都很精彩。

不幸的是,每次点击按钮都会记录下这些内容:

20160229:143610.598   [http-/0.0.0.0:8080-2] WARNING javax.enterprise.resource.webcontainer.jsf.lifecycle - Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}': javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
    at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
    at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
    at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at javax.faces.component.UICommand.broadcast(UICommand.java:300) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
[...]
20160229:143610.600   [http-/0.0.0.0:8080-2] SEVERE javax.enterprise.resource.webcontainer.jsf.context - javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
    at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
    at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447)
    at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
    at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

任何有想法的人?非常感谢提前!

1 个答案:

答案 0 :(得分:0)

只是一个想法 - 添加&#34;方法签名&#34;属性为<composite:attribute name="ajaxListener" />