复合组件的javax.faces.event.AjaxBehaviorEvent方法的javax.el.PropertyNotFoundException

时间:2016-04-11 21:02:18

标签: jsf primefaces propertynotfoundexception methodexpression

我正在尝试使用基于我在Internet上找到的信息的ajax事件实现一个简单的复合组件,但我总是得到 错误javax.el.PropertyNotFoundException

我已经找到了解决方案,我无法弄清楚我做错了什么。

Enviroment:Jboss eap 5.1,Mojarra 2.1.6,primefaces 3.4.2 我无法切换到更高版本的jboss,因为我正在处理现有的应用程序而且我只做了一些改进。

以下是代码的快照。

timeselect.xhtml:

                              

 <composite:implementation>     
    <h:outputLabel for="ddTime" value="Time:" style="font-weight:bold"/>                        
        <p:selectOneMenu id="ddTime" value="cc.attrs.value" style="width:125px" immediate="false">
            <f:selectItem itemLabel="Select One" itemValue="" />
            <f:selectItem itemLabel="Label1" itemValue="ID1" />
             <f:selectItem itemLabel="Label2" itemValue="ID2" />
            <f:selectItem itemLabel="Label3" itemValue="ID3" />
            <p:ajax event="change" listener="#{cc.timelistener}" process="@this" required="true"/>
    </p:selectOneMenu>  
  </composite:implementation>

组件Bean:

@FacesComponent("timeselect")
public class TimeSelectCC extends UINamingContainer {

    public TimeSelectCC() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public String getFamily() {
        return "javax.faces.NamingContainer"; 
    }

    public void timelistener(AjaxBehaviorEvent event) {
        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression ajaxEventListener = (MethodExpression) getAttributes().get("timelistener");
        if(ajaxEventListener != null){
            ajaxEventListener.invoke(context.getELContext(), new Object[] { event });
        }
    }
}

从xhtml页面调用:     
    

<myc:timeselect value="#{pieChartBean.selectedTime}"  timelistener="#{pieChartBean.timeValChange}" /> 

//here - one more label & one more select

</h:panelGrid>
</ui:define>

Managed bean中的方法叫做:

@ManagedBean(name = "pieChartBean")
@ViewScoped

..... 

public void timeValChange(AjaxBehaviorEvent  event){

    //code here

}

错误:(使用完整堆栈跟踪更新)

SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-127.0.0.1-8080-2) Error Rendering View[/pages/tStats.xhtml]: javax.el.PropertyNotFoundException: The class 'com.mbean.PieChartManagedBean' does not have the property 'timeValChange'.
    at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661) [:1.0.0.Final]
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:290) [:1.0.0.Final]
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [:2.1.6-SNAPSHOT]
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [:2.1.6-SNAPSHOT]
    at org.apache.el.parser.AstValue.getValue(AstValue.java:134) [:6.1.0.Final]
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187) [:6.1.0.Final]
    at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) [:2.1.6-SNAPSHOT]
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.6-SNAPSHOT]
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:56) [:]
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:44) [:]
    at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51) [:]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [:2.1.6-SNAPSHOT]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.1.6-SNAPSHOT]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [:2.1.6-SNAPSHOT]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final]
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_38]

2016-04-14 00:59:02,115 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/StatsAdmin].[Faces Servlet]] (http-127.0.0.1-8080-2) Servlet.service() for servlet Faces Servlet threw exception: javax.el.PropertyNotFoundException: The class 'com.mbean.PieChartManagedBean' does not have the property 'timeValChange'.
    at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661) [:1.0.0.Final]
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:290) [:1.0.0.Final]
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [:2.1.6-SNAPSHOT]
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [:2.1.6-SNAPSHOT]
    at org.apache.el.parser.AstValue.getValue(AstValue.java:134) [:6.1.0.Final]
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187) [:6.1.0.Final]
    at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77) [:2.1.6-SNAPSHOT]
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185) [:2.1.6-SNAPSHOT]
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) [:2.1.6-SNAPSHOT]
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.6-SNAPSHOT]
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:56) [:]
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:44) [:]
    at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51) [:]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [:2.1.6-SNAPSHOT]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [:2.1.6-SNAPSHOT]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.1.6-SNAPSHOT]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.1.6-SNAPSHOT]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [:2.1.6-SNAPSHOT]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final]
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_38]

0 个答案:

没有答案