Bonjour,
J'ai besoin de votre aide.c'est urgent.
J'ai suivis ce que vous avez proposé comme solution à insertion de données à la base depuis Hibernate.
Je travaille sur un projet Hibernate JSF 2.0 sur netbeans 6.8 et j'aimerais insérer des employes dans champs dans ma base; Voici ce que j'ai fait:
-------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package Authentif; public class Authentification implements java.io.Serializable { private int idauth; private String loginauth; private String passauth; public Authentification() { } public Authentification(int idauth) { this.idauth = idauth; } public Authentification(int idauth, String loginauth, String passauth) { this.idauth = idauth; this.loginauth = loginauth; this.passauth = passauth; } public int getIdauth() { return this.idauth; } public void setIdauth(int idauth) { this.idauth = idauth; } public String getLoginauth() { return this.loginauth; } public void setLoginauth(String loginauth) { this.loginauth = loginauth; } public String getPassauth() { return this.passauth; } public void setPassauth(String passauth) { this.passauth = passauth; } }
--------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package Authentif; import org.hibernate.Session; import java.util.List; import org.hibernate.Query; public class AuthHelper { Session session = null; public AuthHelper(){ this.session = AuthHibernateUtil.getSessionFactory().getCurrentSession(); } public void saveClient(Authentification authentif) { //Authentification authentif = new Authentification(); org.hibernate.Transaction tx =session.beginTransaction(); //authentif.setIdauth(11); authentif.setIdauth(authentif.getIdauth()); authentif.setLoginauth(authentif.getLoginauth()); authentif.setPassauth(authentif.getPassauth()); session.save(authentif); tx.commit(); session.close(); } } -------------------------------------------------------------------------- package Authentif; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import java.util.List; @ManagedBean(name="authentifBean") @SessionScoped public class authentifBean { /** Creates a new instance of authentifBean */ AuthHelper helper; Authentification auth; List<Authentification> authList; public authentifBean() { helper = new AuthHelper(); } public Authentification getAuth(){return auth;} public void setAuth(Authentification auth){this.auth=auth;} public String validateLogin(){ helper.saveClient(this.auth); return "index"; } }
-----------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?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"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <center><h:form id="helloForm"> <h:panelGrid columns="3"> <h:outputText value="id"/> <h:inputText id="idauth" value="#{authentifBean.auth.idauth()}" required="true"/> <h:message for="idauth" styleClass="error"/> <h:outputText value="Login"/> <h:inputText id="login" value="#{authentifBean.auth.loginauth}" required="true"/> <h:message for="login" styleClass="error"/> <h:outputText value="mot de passe"/> <h:inputSecret id="passauth" value="#{authentifBean.auth.passauth}" required="true"/> <h:message for="passauth" styleClass="error"/> <h:commandButton action="#{authentifBean.validateLogin}" value="S'authentifier"/> </h:panelGrid> </h:form></center> </h:body> </html>
Il me renvoie une erreur :
-------------------------------------------------------------------------/nextpage.xhtml @13,100 value="#{authentifBean.auth.idauth()}": Target Unreachable, 'null' returned null
Voici le Stack Trace de mon erreur :
javax.el.PropertyNotFoundException: /nextpage.xhtml @13,100 value="#{authentifBean.auth.idauth()}": Target Unreachable, 'null' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
at javax.faces.component.UIInput.validate(UIInput.java:934)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
at javax.faces.component.UIInput.processValidators(UIInput.java:691)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIForm.processValidators(UIForm.java:243)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
S'il vous plait que quelqu'un m'aide c'est très urgent Merci d'avance.
Partager