0

i'm using JSF 2.2.8 and hibernate, i have this enum in my modele below and when i run my prject this error appears

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

Here is the structure of the activite table which contains the fields of the enumeration.

activite(idt_activite,description,institution,nom)

Here is the 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;
}   
}

And which has a relation with the Activite modele below

@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;
}
}

Here is my my backing bean

@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);
}
}

and here is my XHTML i have this 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>
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
CHARAFI Saad
  • 984
  • 1
  • 12
  • 33

0 Answers0