I wrote this XHTML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>TODO supply a title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<link rel="stylesheet" type="text/css" href="dhtmlcombo.css" />
</h:head>
<body>
<p:growl id="growl" sticky="true" showDetail="true"/>
<p:tab id="personal" title="Personal">
<p:panel header="Personal Details">
<p:messages />
<h:panelGrid columns="2" columnClasses="label, value">
<h:outputText value="Firstname: *" />
<p:inputText value="#{compteController.compte.nom}"
required="true" label="Firstname"/>
<h:outputText value="Lastname: *" />
<p:inputText value="#{compteController.compte.prenom}"
required="true" label="Lastname"/>
<h:outputText value="Age: " />
<p:inputText value="#{compteController.compte.age}" />
</h:panelGrid>
<p:commandButton value="Valider" actionListener="#
{compteController.create()}" update="growl"
process="@this"/>
</p:panel>
</p:tab>
</body>
and these two java file :
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
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.xml.bind.annotation.XmlRootElement;
@ManagedBean
@Entity
@Table(name = "compte")
public class Compte implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "nom")
private String nom;
@Basic(optional = false)
@Column(name = "prenom")
private String prenom;
@Basic(optional = false)
@Column(name = "age")
private String age;
public Compte() {
}
public Compte(String login) {
this.nom = login;
}
public Compte(String login, String password, String email) {
this.nom = login;
this.prenom= password;
this.age = email;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
}
and this file :
package org.utilisation.db.org.controller;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import org.utilisation.db.org.Compte;
import org.utilisation.db.org.dao.CompteFacade;
@ManagedBean
public class CompteController {
private Compte compte;
@EJB
private CompteFacade compteFacade;
public Compte getCompte() {
return compte;
}
public void create()
{
compteFacade.create(compte);
}
}
And my problem is that the data registered won't get uploaded in the SQL. Maybe i am missing a line or maybe did I miss something while making the configuration. The table is perfectly created but when I enter new data and try to register them it simply does not work : My dataBase stays empty.
I was hoping that someone could help me unsderstand the cause of the issue since i couldn't find anything appropriate on the web
Aucun commentaire:
Enregistrer un commentaire