[PrimeFaces] Agenda dynamique
Bonjour,
J'ai utilisé PrimeFaces pour un agenda qui affiche les tâches des utilisateurs d'une façon dynamique.
Voilà le message d'erreur:
Citation:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Impossible d?instancier la classe «com.src.jsf.ScheduleController».
root cause
com.sun.faces.mgbean.ManagedBeanCreationException: Impossible d?instancier la classe «com.src.jsf.ScheduleController».
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
class controller:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public class ScheduleController implements Serializable {
@EJB
private AgendatacheFacade agendatacheFacade;
private ScheduleModel eventModel;
private ScheduleEvent event = new DefaultScheduleEvent();
List<Agendatache> listtache;
public ScheduleController() {
listtache = agendatacheFacade.getTache();
eventModel = new DefaultScheduleModel();
Agendatache tache=new Agendatache();
String desc="";
Date datedebut=new Date();
Date datefin = new Date();
for(int i=0; i<listtache.size(); i++){
tache=listtache.get(i);
desc=tache.getDescripTache();
datedebut=tache.getDateDebut();
datefin=tache.getDateFin();
eventModel.addEvent(new DefaultScheduleEvent(desc,datedebut, datefin));
}
} |
Page Web
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets
<h:form id="form">
<p:growl id="messages" showDetail="true" />
<p:schedule id="schedule" value="#{scheduleController.eventModel}" widgetVar="myschedule">
<p:ajax event="dateSelect" listener="#{scheduleController.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
<p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
<p:ajax event="eventMove" listener="#{scheduleController.onEventMove}" update="messages" />
<p:ajax event="eventResize" listener="#{scheduleController.onEventResize}" update="messages" />
</p:schedule>
<p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
<h:panelGrid id="eventDetails" columns="2">
<h:outputLabel for="title" value="Title:" />
<p:inputText id="title" value="#{scheduleController.event.title}" required="true"/>
<h:outputLabel for="from" value="From:" />
<p:inputMask id="from" value="#{scheduleController.event.startDate}" mask="99/99/9999">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:inputMask>
<h:outputLabel for="to" value="To:" />
<p:inputMask id="to" value="#{scheduleController.event.endDate}" mask="99/99/9999">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:inputMask>
<h:outputLabel for="allDay" value="All Day:" />
<h:selectBooleanCheckbox id="allDay" value="#{scheduleController.event.allDay}" />
<p:commandButton type="reset" value="Reset" />
<p:commandButton id="addButton" value="Save" actionListener="#{scheduleController.addEvent}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();"/>
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</html> |
Quelqu'un saurait-il m'indiquer d'où peut venir le problème ?
Merci d'avance pour votre aide.
Primefaces agenda dynamique
Bonjour jeffray03,
voila la classe agendatacheFacade:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.src.sessions;
import com.src.jpa.Agendatache;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/**
*
* @author Accent-Saidi
*/
@Stateless
public class AgendatacheFacade extends AbstractFacade<Agendatache> {
@PersistenceContext(unitName = "GTAappPU")
private EntityManager em;
protected EntityManager getEntityManager() {
return em;
}
public AgendatacheFacade() {
super(Agendatache.class);
}
public List<Agendatache> getTache() {
Query query = em.createNamedQuery("Agendatache.findAll");
return query.getResultList();
}
} |
et voilà le medel jpa:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.src.jpa;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Accent-Saidi
*/
@Entity
@Table(name = "agendatache", catalog = "gtadatabase", schema = "")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Agendatache.findAll", query = "SELECT a FROM Agendatache a"),
@NamedQuery(name = "Agendatache.findByNumTache", query = "SELECT a FROM Agendatache a WHERE a.numTache = :numTache"),
@NamedQuery(name = "Agendatache.findByDescripTache", query = "SELECT a FROM Agendatache a WHERE a.descripTache = :descripTache"),
@NamedQuery(name = "Agendatache.findByDateDebut", query = "SELECT a FROM Agendatache a WHERE a.dateDebut = :dateDebut"),
@NamedQuery(name = "Agendatache.findByDureeTache", query = "SELECT a FROM Agendatache a WHERE a.dureeTache = :dureeTache"),
@NamedQuery(name = "Agendatache.findByDateFin", query = "SELECT a FROM Agendatache a WHERE a.dateFin = :dateFin"),
@NamedQuery(name = "Agendatache.findByAffecteePar", query = "SELECT a FROM Agendatache a WHERE a.affecteePar = :affecteePar")})
public class Agendatache implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "numTache")
private Integer numTache;
@Size(max = 254)
@Column(name = "descripTache", length = 254)
private String descripTache;
@Column(name = "dateDebut")
@Temporal(TemporalType.TIMESTAMP)
private Date dateDebut;
@Column(name = "dureeTache")
private Integer dureeTache;
@Column(name = "dateFin")
@Temporal(TemporalType.TIMESTAMP)
private Date dateFin;
@Size(max = 245)
@Column(name = "affecteePar", length = 245)
private String affecteePar;
@JoinColumn(name = "idEtat", referencedColumnName = "idEtat")
@ManyToOne
private Etat idEtat;
@JoinColumn(name = "numDmd", referencedColumnName = "numDmd")
@ManyToOne
private Demande numDmd;
@JoinColumn(name = "mat", referencedColumnName = "mat")
@ManyToOne
private User mat;
public Agendatache() {
}
public Agendatache(Integer numTache) {
this.numTache = numTache;
}
public Integer getNumTache() {
return numTache;
}
public void setNumTache(Integer numTache) {
this.numTache = numTache;
}
public String getDescripTache() {
return descripTache;
}
public void setDescripTache(String descripTache) {
this.descripTache = descripTache;
}
public Date getDateDebut() {
return dateDebut;
}
public void setDateDebut(Date dateDebut) {
this.dateDebut = dateDebut;
}
public Integer getDureeTache() {
return dureeTache;
}
public void setDureeTache(Integer dureeTache) {
this.dureeTache = dureeTache;
}
public Date getDateFin() {
return dateFin;
}
public void setDateFin(Date dateFin) {
this.dateFin = dateFin;
}
public String getAffecteePar() {
return affecteePar;
}
public void setAffecteePar(String affecteePar) {
this.affecteePar = affecteePar;
}
public Etat getIdEtat() {
return idEtat;
}
public void setIdEtat(Etat idEtat) {
this.idEtat = idEtat;
}
public Demande getNumDmd() {
return numDmd;
}
public void setNumDmd(Demande numDmd) {
this.numDmd = numDmd;
}
public User getMat() {
return mat;
}
public void setMat(User mat) {
this.mat = mat;
}
@Override
public int hashCode() {
int hash = 0;
hash += (numTache != null ? numTache.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Agendatache)) {
return false;
}
Agendatache other = (Agendatache) object;
if ((this.numTache == null && other.numTache != null) || (this.numTache != null && !this.numTache.equals(other.numTache))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.src.jpa.Agendatache[ numTache=" + numTache + " ]";
}
} |
Primefaces agenda dynamique
Bonjour OButterlin;
Pourquoi je peux pas utiliser le constructeur pour l'initialisation?
Citation:
Envoyé par
OButterlin
Je me répète, il ne FAUT pas utiliser le constructeur pour l'initialisation :roll:
et dans ce cas!! c'est quoi la solution.
Merci pour votre aide
Primefaces agenda dynamique
Oui je déclare ScheduleController comme un managedBean
Citation:
Envoyé par
jeffray03
Salut
as-tu declaré
comme un managedBean? si oui ou?
Je declare comme ça
Code:
1 2 3 4
|
@ManagedBean(name = "scheduleController")
@SessionScoped
public class ScheduleController implements Serializable { |
et j'ai essayé la déclarer comme vous m'indiquez et ça ne marche plus
Citation:
peux-tu nous montrer ou si tu utilises un CDI il faudra l´annoter @Named
comme ceci:
Code:
1 2 3
|
@ManagedBean
public class ScheduleController { |
ou avec CDI
Code:
1 2 3
|
@Named
public class ScheduleController { |
et cela devrait marcher.
Merci
Primefaces agenda dynamique
Re-Bonjour,
Je pense que le problème d'instanciation est résolu.
j'ai mis le code au sein d'une méthode.
Maintenant j'ai un autre problème lors de l'injection des ressources dans le bean géré "scheduleController"
je sais pas d'où vient le problème!!:(