Pb affichage d'un <rich:extendedDataTable>
Bonjour,
Je voudrais remplir une <rich:extendedDataTable> avec un liste récupérée à partir de ma base de données qui est mappée avec Hibernate.. Le probleme c que lorsque j'affiche ma page JSF, le tableau parait réduit (sans colonnes et sans données, juste son en-tête)
Je vous poste le code de ma page jsf (.xhtml) :
consulterUserTable.xhtml :
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
| <!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="templ/template.xhtml">
<ui:define name="region1">
<h:form>
<rich:simpleTogglePanel label="Liste des utilisateurs" id="tbl">
<rich:extendedDataTable binding="#{utilisateurBeanTable.tableConsult}"
onRowMouseOver="this.style.backgroundColor='#B5CEFD'"
onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
onRowClick="this.style.backgroundColor='#F1F1F1'"
value="#{utilisateurBeanTable.utilisateursList}" var="use" id="tableUser"
width="580px" height="436" rows="7">
<rich:column sortable="false" label="id user">
<f:facet name="header">
<h:outputText value="Identifiant User" />
</f:facet>
<h:outputText value="#{use.id}" />
</rich:column>
<rich:column sortable="true" sortBy="#{usenomUser}"
filterBy="#{use.nomUser}" filterEvent="onkeyup"
width="170px" label="Nom User">
<f:facet name="header">
<h:outputText value="Nom User" />
</f:facet>
<h:outputText value="#{use.nomUser}}" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Prenom User" />
</f:facet>
<h:outputText value="#{use.prenomUser}" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<h:outputText value="#{use.loginUser}" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Password" />
</f:facet>
<h:outputText value="#{use.paswordUser}" />
</rich:column>
<f:facet name="footer">
<rich:datascroller />
</f:facet>
</rich:extendedDataTable>
</rich:simpleTogglePanel>
</h:form>
</ui:define>
</ui:composition>
</html> |
Voici le code de mon bean :
UtilisateurBeanTable.java :
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
| package com.oxia.beanjsf;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.component.html.HtmlAjaxCommandLink;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIExtendedDataTable;
import com.oxia.hibernate.Utilisateur;
import com.oxia.hibernate.base.*;
public class UtilisateurBeanTable {
private UIExtendedDataTable tableConsult;
private List<Utilisateur> utilisateursList;
public UIExtendedDataTable getTableConsult() {
return tableConsult;
}
public void setTableConsult(UIExtendedDataTable tableConsult) {
this.tableConsult = tableConsult;
}
public List<Utilisateur> getUtilisateursList() {
Session session = null;
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Using from Clause
String SQL_QUERY ="from Utilisateur utilisateur";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate(); it.hasNext();){
Utilisateur user = (Utilisateur)it.next();
System.out.println("Nom Utilisateur : "+user.getNomUser());
System.out.println("Prenom Utilisateur : "+user.getPrenomUser());
}
utilisateursList=session.createQuery(SQL_QUERY).list();
session.close();
return utilisateursList;
}
public void setUtilisateursList(List<Utilisateur> utilisateursList) {
this.utilisateursList = utilisateursList;
}
} |
La classe Utilisateur.java :
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
| package com.oxia.hibernate;
import com.oxia.hibernate.base.BaseUtilisateur;
public class Utilisateur extends BaseUtilisateur {
private static final long serialVersionUID = 1L;
/*[CONSTRUCTOR MARKER BEGIN]*/
public Utilisateur () {
super();
}
/**
* Constructor for primary key
*/
public Utilisateur (java.lang.Long id) {
super(id);
}
/*[CONSTRUCTOR MARKER END]*/
} |
la classe BaseUtilisateur.java :
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
| package com.oxia.hibernate.base;
import java.io.Serializable;
/**
* This is an object that contains data related to the utilisateur table.
* Do not modify this class because it will be overwritten if the configuration file
* related to this class is modified.
* @hibernate.class
* table="utilisateur"
*/
public abstract class BaseUtilisateur implements Serializable {
public static String REF = "Utilisateur";
public static String PROP_PASWORD_USER = "PaswordUser";
public static String PROP_MAIL_USER = "MailUser";
public static String PROP_PRENOM_USER = "PrenomUser";
public static String PROP_POSITION_USER = "PositionUser";
public static String PROP_LOGIN_USER = "LoginUser";
public static String PROP_ID = "Id";
public static String PROP_NOM_USER = "NomUser";
// constructors
public BaseUtilisateur () {
initialize();
}
/**
* Constructor for primary key
*/
public BaseUtilisateur (java.lang.Long id) {
this.setId(id);
initialize();
}
protected void initialize () {}
private int hashCode = Integer.MIN_VALUE;
// primary key
private java.lang.Long id;
// fields
private java.lang.String nomUser;
private java.lang.String prenomUser;
private java.lang.String loginUser;
private java.lang.String paswordUser;
private java.lang.String mailUser;
private java.lang.String positionUser;
// collections Modify by laouini Moez (teamsware)
private java.util.Set produits;
private java.util.Set groupeUsers;
private java.util.Set artifacts;
/**
* Return the unique identifier of this class
* @hibernate.id
* generator-class="sequence"
* column="ID_USER"
*/
public java.lang.Long getId () {
return id;
}
public void setId (java.lang.Long id) {
this.id = id;
this.hashCode = Integer.MIN_VALUE;
}
public java.lang.String getNomUser () {
return nomUser;
}
public void setNomUser (java.lang.String nomUser) {
this.nomUser = nomUser;
}
public java.lang.String getPrenomUser () {
return prenomUser;
}
public void setPrenomUser (java.lang.String prenomUser) {
this.prenomUser = prenomUser;
}
public java.lang.String getLoginUser () {
return loginUser;
}
public void setLoginUser (java.lang.String loginUser) {
this.loginUser = loginUser;
}
public java.lang.String getPaswordUser () {
return paswordUser;
}
public void setPaswordUser (java.lang.String paswordUser) {
this.paswordUser = paswordUser;
}
public java.lang.String getMailUser () {
return mailUser;
}
public void setMailUser (java.lang.String mailUser) {
this.mailUser = mailUser;
}
public java.lang.String getPositionUser () {
return positionUser;
}
public void setPositionUser (java.lang.String positionUser) {
this.positionUser = positionUser;
}
public java.util.Set getProduits () {
return produits;
}
public void setProduits (java.util.Set produits) {
this.produits = produits;
}
public void addToProduits (com.oxia.hibernate.Produit produit) {
if (null == getProduits()) setProduits(new java.util.TreeSet());
getProduits().add(produit);
}
public java.util.Set getGroupeUsers () {
return groupeUsers;
}
public void setGroupeUsers (java.util.Set groupeUsers) {
this.groupeUsers = groupeUsers;
}
public void addToGroupeUsers (com.oxia.hibernate.GroupeUser groupeUser) {
if (null == getGroupeUsers()) setGroupeUsers(new java.util.TreeSet());
getGroupeUsers().add(groupeUser);
}
public java.util.Set getArtifacts () {
return artifacts;
}
public void setArtifacts (java.util.Set artifacts) {
this.artifacts = artifacts;
}
public void addToArtifacts (com.oxia.hibernate.Artifact artifact) {
if (null == getArtifacts()) setArtifacts(new java.util.TreeSet());
getArtifacts().add(artifact);
}
public boolean equals (Object obj) {
if (null == obj) return false;
if (!(obj instanceof com.oxia.hibernate.Utilisateur)) return false;
else {
com.oxia.hibernate.Utilisateur utilisateur = (com.oxia.hibernate.Utilisateur) obj;
if (null == this.getId() || null == utilisateur.getId()) return false;
else return (this.getId().equals(utilisateur.getId()));
}
}
public int hashCode () {
if (Integer.MIN_VALUE == this.hashCode) {
if (null == this.getId()) return super.hashCode();
else {
String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
this.hashCode = hashStr.hashCode();
}
}
return this.hashCode;
}
public String toString () {
return super.toString();
}
} |
Je rappelle que mon probleme est l'affichage de la table qui s'affiche vide (juste son en-tete, meme pas de colonnes ni de données, pourtant, tout est bine déclaré dans ma page jsf)
Je vous remercie pour votre aide
je vous remrcie pour