javax.el.PropertyNotFoundException:Property' institution'在类型ma.controle.gestion.modele.Activite上找不到

时间:2017-03-30 09:17:04

标签: jsf enums el propertynotfoundexception

我正在使用JSF 2.2.8和hibernate,我在下面的模型中有这个枚举,当我运行我的程序时出现这个错误

Caused by: javax.el.PropertyNotFoundException: Property 'institution' not found on type ma.controle.gestion.modele.Activite

以下是包含枚举字段的活动表的结构。

activite(idt_activite,description,institution,nom)

这是ENUM

public enum Institution {
RCAR("RCAR"),
CNRA("CNRA");

private String label;

private Institution(String label) {
    this.label = label;
}

public String getLabel() {
    return label;
}

public void setLabel(String label) {
    this.label = label;
}   
}

与下面的Activite模型有关系

@Entity
public class Activite implements Serializable {


private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long idt_activite;
private String nom;
private String description;

@Enumerated(EnumType.STRING)
private Institution institution;

public Activite() {
    super();
}

public Long getIdt_activite() {
    return idt_activite;
}


public void setIdt_activite(Long idt_activite) {
    this.idt_activite = idt_activite;
}


public String getNom() {
    return nom;
}
public void setNom(String nom) {
    this.nom = nom;
}
public String getDescription() {
    return description;
}
public void setDescription(String description) {
    this.description = description;
}
}

这是我的支持豆

@ManagedBean(name="activiteBean")
@ViewScoped
public class ActiviteBean implements Serializable{


private static final long serialVersionUID = 1L;

private Long identifiant;
private String nom;
private String description;

private Institution institution;

private List<Activite> activites;

private Activite activite = new Activite();

@ManagedProperty(value = "#{activiteService}")
private IActiviteService activiteService;



public ActiviteBean() {
    super();
}

@PostConstruct
public void init(){
    activites=activiteService.listActivites();
}

public SelectItem[] getInstitutionValues() {
    SelectItem[] items = new SelectItem[Institution.values().length];
    int i = 0;
    for(Institution g: Institution.values()) {
      items[i++] = new SelectItem(g, g.getLabel());
    }
    return items;
  }


public void save(){
    activiteService.addActivite(activite);
    activites=activiteService.listActivites();
    this.activite=initBean();
}

public Activite initBean()
{
    this.activite.setNom("");
    this.activite.setDescription("");
    //this.activite.setStructure(null);
    return activite;
}

public void delete(Activite activite){
    System.out.println("deleeete");
    activiteService.deleteActivite(activite);
    System.out.println("after delete");
    activites=activiteService.listActivites();
}

public Long getIdentifiant() {
    return identifiant;
}

public void setIdentifiant(Long identifiant) {
    this.identifiant = identifiant;
}

public String getNom() {
    return nom;
}

public void setNom(String nom) {
    this.nom = nom;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public Activite getActivite() {
    return activite;
}

public void setActivite(Activite activite) {
    this.activite = activite;
}

public IActiviteService getActiviteService() {
    return activiteService;
}

public void setActiviteService(IActiviteService activiteService) {
    this.activiteService = activiteService;
}

public List<Activite> getActivites() {
    return activites;
}

public void setActivites(List<Activite> activites) {
    this.activites = activites;
}


public Institution getInstitution() {
    return institution;
}

public void setInstitution(Institution institution) {
    this.institution = institution;
}


public void update(Activite activite){
    activiteService.addActivite(activite);
    initBean();
}
public void onEdit(RowEditEvent event) {
    Activite activiteEdit = (Activite) event.getObject();
    System.out.println("Updaaaate");
    update(activiteEdit);
    System.out.println("Updaaaate aprés");
    FacesMessage msg = new FacesMessage("Actvite à jour", ((Activite) event.getObject()).getNom());
    FacesContext.getCurrentInstance().addMessage(null, msg);

}

public void onCancel(RowEditEvent event) {
    FacesMessage msg = new FacesMessage("mise à jour annulée", ((Activite) event.getObject()).getNom());
    FacesContext.getCurrentInstance().addMessage(null, msg);
}
}

这是我的XHTML,我有这个selectOneMenu

                       <p:outputLabel for="institution" value="Institution"/>
                        <h:panelGroup >         
                            <p:selectOneMenu id="institution" value="#{activiteBean.institution}">
                                <f:selectItem itemLabel="Select One" itemValue="" />
                                <f:selectItems value="#{activiteBean.institutionValues}" />
                            </p:selectOneMenu>
                         </h:panelGroup>

0 个答案:

没有答案