handlePartialResponseError SEVERE:javax.el.MethodNotFoundException:找不到方法:allser.com.company.jsfimpl.AxeBean@25f8da.onAxeChosen()

时间:2015-04-14 09:06:22

标签: java spring jsf-2 primefaces

spring项目在网络端实现jsf primefaces,即时工作(Dialog Framework - Data)数据表显示,但是当我选择一行时它会在下面显示我的错误,所以这里是我的代码和错误

Data.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<body>
    <h:form>
    <p:growl id="growl" showDetail="true" />
    <p:commandButton value="Select Axe" icon="ui-icon-extlink" 
     actionListener="#{axeBean.chooseAxe()}">
        <p:ajax event="dialogReturn" listener="#{axeBean.onAxeChosen()}" 
        update="growl" />
    </p:commandButton>
</h:form>
</body>
</html>

这是我的ManagedBean

package allser.com.company.jsfimpl;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;


import javax.faces.context.FacesContext;

import org.primefaces.context.RequestContext;
import org.primefaces.event.SelectEvent;
//import org.primefaces.event.SelectEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import allser.com.company.entities.Axe;
import allser.com.company.entities.AxeCategorie;
import allser.com.company.entities.Organisme;
import allser.com.company.metier.IMetier;

@ManagedBean(name = "axeBean")
@Scope
@Component
    public class AxeBean {

        @Autowired
        private IMetier metier;

        private int idAxeCategorie;

        public int getIdAxeCategorie() {
            return idAxeCategorie;
        }

        public void setIdAxeCategorie(int idAxeCategorie) {
            this.idAxeCategorie = idAxeCategorie;
        }

        public IMetier getMetier() {
            return metier;
        }

        public void setMetier(IMetier metier) {
            this.metier = metier;
        }

        public Axe axe;

        public Axe getAxe() {
            return axe;
        }

        public void setAxe(Axe axe) {
            this.axe = axe;
        }

        public AxeBean() {
            axe = new Axe();
        }

        public String ajouter() {
            Organisme org = metier.getOrganisme(1);
            axe.setOrganisme(org);
            AxeCategorie axCat = metier.getAxeCategorie(this.idAxeCategorie);
            axe.setAxeCategorie(axCat);
            metier.addAxe(axe);
            axe = new Axe();
            return "PlanifieAxe";
        }

        public List<AxeCategorie> listCategorie() {
            return metier.getALLAxesCategorie();
        }

        public List<Axe> listAxes() {

            return metier.getALLAxes();
        }



         @PostConstruct
            public List<Axe> init() {
               return   metier.getALLAxes();
            }


        public void chooseAxe() {

            RequestContext.getCurrentInstance().openDialog("selectAxe");

        }

        public void onAxeChosen(SelectEvent event) {
        System.out.println("je suis dans onCarChosen ");
            Axe axe = (Axe) event.getObject();
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Planifie Selected","Id:"+axe.getIdAxe());
            System.out.println("voila "+axe.getIdAxe());

            FacesContext.getCurrentInstance().addMessage(null, message);
        }


        public void selectCarFromDialog(Axe axe) {
            RequestContext.getCurrentInstance().closeDialog(axe);
        }

    }

selectedAxe.xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

 <h:head>
        <title>Axes</title>
                <style type="text/css">
            .ui-widget {
                font-size: 90%;
            }
        </style>
    </h:head>

    <h:body>
    <h:form>

        <p:dataTable var="axe" value="#{axeBean.listAxes()}" paginator="true"
            rows="3">
            <p:column headerText="Ville Depart">
                <h:outputText value="#{axe.villeDepart}" />
            </p:column>

            <p:column headerText="Ville Arrivee">
                <h:outputText value="#{axe.villeArrivee}" />
            </p:column>

            <p:column headerText="Frequence">
                <h:outputText value="#{axe.frequence}" />
            </p:column>

            <p:column headerText="Categorie">
                <h:outputText value="#{axe.axeCategorie.axeType}" />
            </p:column>

            <p:column headerText="Select Axe">
                    <p:commandButton icon="ui-icon-search" actionListener="#{axeBean.selectCarFromDialog(axe)}" />
                </p:column>
        </p:dataTable>
    </h:form>
    </h:body>

</html>

这是我运行程序时出现的错误

vr. 14, 2015 7:41:46 AM com.sun.faces.lifecycle.ApplyRequestValuesPhase execute
WARNING: Method not found: allser.com.company.jsfimpl.AxeBean@7c45e5.onAxeChosen()
javax.el.MethodNotFoundException: Method not found: allser.com.company.jsfimpl.AxeBean@7c45e5.onAxeChosen()
    at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:260)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:271)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
    at org.primefaces.behavior.ajax.AjaxBehaviorListenerImpl.processCustomListener(AjaxBehaviorListenerImpl.java:88)
    at org.primefaces.behavior.ajax.AjaxBehaviorListenerImpl.processArgListener(AjaxBehaviorListenerImpl.java:73)
    at org.primefaces.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:57)
    at org.primefaces.event.SelectEvent.processListener(SelectEvent.java:40)
    at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:804)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:755)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

1 个答案:

答案 0 :(得分:0)

堆栈跟踪确切地告诉您问题所在。

<p:ajax event="dialogReturn" listener="#{axeBean.onAxeChosen()}" 
    update="growl" />

public void onAxeChosen(SelectEvent event) {...}

不符合要求。从java方法中删除SelectEvent event或从xhtml的listener属性中删除EL中的()