我有这个非常简单的页面,这让我发疯。基本上我在一个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>
因此,当我单击其中任何一个按钮时,我都会收到错误消息。这很奇怪,因为我以 excat 相同的方式从其他页面调用其他 bean 中的方法。
有任何想法吗?谢谢。
我正在使用 JDK 6u35、richfaces 4.2.1.Final、tomcat 7 和 JSF 2.1.6