0

私はこの非常に単純なページを持っていますが、それは私を夢中にさせています. 基本的に、Bean でメソッドを呼び出す 2 つのボタンがありますが、取得するたびに呼び出されません。

javax.el.MethodNotFoundException: /vues/vehicule/creationVehicule.xhtml @49,94 action="#{creationVehicule.creer}": メソッドが見つかりません: fr.efrei.gpa.web.beans.vehicule.ModificationVehiculeBean@1387498.creer ()

これは私のコントローラーです(インポートを削除しました)

@Getter
@Setter
@ManagedBean(name = "creationVehicule")
@ViewScoped
public class CreationVehiculeBean implements Serializable{
    //
    private static final long serialVersionUID = 4790600937909196533L;
    private String immatriculation;
    private Date dateAchat;
    private String marque;
    private String modele;
    private String kilometrage;
    private String puissance;
    private String etat;

    private VehiculeService vehiculeService = new VehiculeDelegate();

    public void creer() throws Exception{
        Vehicule v = new Vehicule();
        v.setImmatriculation(immatriculation);
        v.setKilometrage(kilometrage);
        v.setMarque(marque);
        v.setModele(modele);
        v.setPuissance(puissance);
        v.setEtat("etat");
        v.setDateAchat(dateAchat);
        int id = vehiculeService.create(v);

        FacesContext.getCurrentInstance().getExternalContext().redirect("/web-office/vue/vehicule/rechercherContrat.xhtml&id="+Integer.toString(id));
    }

    public String annuler(){
        return "/vues/vehicule/rechercheVehicule?faces-redirect=true";
    }

}

そしてこれが私の見解です

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:cogepat="http://cogepat.com/facelets"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:ccc="http://java.sun.com/jsf/composite/compositeForms"
    xmlns:cccg="http://java.sun.com/jsf/composite/compositeGeneral">

<ui:composition template="/templates/template.xhtml">
    <ui:param name="module" value="vehicules" />
    <ui:define name="title">
        #{msg.CreerUnProduit}
    </ui:define>

    <ui:define name="titreModule">
        #{msg.GestionVehicule}
    </ui:define>

    <ui:define name="onglets">
        <ul>
            <li>
                <a class="tab" href="#{facesContext.externalContext.requestContextPath}/vues/vehicule/rechercheVehicule.xhtml">#{msg.RechercherUnVehicule}</a>
            </li>
            <li>
                <a class="selectedTab" href="#{facesContext.externalContext.requestContextPath}/vues/vehicule/creationVehicule.xhtml">#{msg.CreerUnVehicule}</a>
            </li>
        </ul>
    </ui:define>

    <ui:define name="nav">
        <h:form>
            <h:commandLink id="link1" value="#{msg.vehicules}" action="rechercheVehicule.xhtml" />
                >#{msg.creation}
        </h:form>
    </ui:define>


    <ui:define name="titreOnglet">
        #{msg.FormCreationVehicule}
    </ui:define>

    <ui:define name="corpsContenu">
        <ccc:formVehicule bean="#{creationVehicule}" />
        <div class="boutons">
                <h:commandButton type="submit" value="#{msg.creer}" action="#{creationVehicule.creer}" />
                <h:commandButton type="submit" value="#{msg.annuler}" action="#{creationVehicule.annuler}" />
        </div>
        <br/><br/>
    </ui:define>

</ui:composition>
</html>

そのため、これらのボタンのいずれかをクリックすると、エラーが発生します。同じ方法で他のページから他のBeanのメソッドを呼び出しているので、これは奇妙です。

ボタン

何か案は?ありがとう。

JDK 6u35、richfaces 4.2.1.Final、tomcat 7、および JSF 2.1.6 を使用しています。

4

1 に答える 1

1

例外メッセージをもう一度見てから、特にクラス名を見てください。

fr.efrei.gpa.web.beans.vehicule.ModificationVehiculeBean@1387498.creer()

CreationVehiculeBeanそれはあなたが手元に持っているクラスのFQNではありません。これは、ModificationVehiculeBeanまったく同じマネージドBean名を使用し、クラスローディングで優先された、および/またはマネージドBean登録の最後のマネージドBeanクラスがあることを示しています。

クラスに別のマネージドModificationVehiculeBeanBean名を付けると、この問題が修正されるはずです。

于 2013-01-14T20:34:53.773 に答える