1 pièce(s) jointe(s)
[JSF / Spring / Hibernate] Problème ManagedBean
Bonjour,
Je suis en train de développer une application web en utilisant JSF + Spring + Hibernate. J'ai réussi à amener les données jusqu’à la couche métier service (j'ai testé ça avec un test Junit).
Je suppose que mon problème est dans le managed bean parce que si je lance l'application sous Tomcat, l'interface apparait mais je n'ai pas mes données que je souahite afficher à partir de la base.
Rien ne fonctionne (lister, supprimer, créer ...)
Voilà mon managed Bean
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
| package org.wisetech.geoloc.Bean;
import java.io.Serializable;
import java.util.List;
import org.richfaces.component.UIDataTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.wisetech.geoloc.Interface.ChauffeurService;
import org.wisetech.geoloc.model.Chauffeur;
public class ChauffeurBean extends MessageBean implements Serializable {
private transient ChauffeurService chauffeurService;
private transient UIDataTable dataTable;
private Chauffeur chauffeur;
private boolean init;
private Integer index = 0;
private String message;
private boolean nouveau;
private List<Chauffeur> chauffeur_list;
public ChauffeurBean() {
chauffeur = new Chauffeur();
}
public void ChauffList() {
chauffeur_list = chauffeurService.findAll();
}
public void viderchamps() {
message = "";
changeretat();
this.chauffeur = new Chauffeur();
nouveau = true;
}
public void annuler() {
message = "";
chauffeur_list = (List<Chauffeur>) getChauffeur_list();
chauffeur = (Chauffeur) chauffeur_list.get(index);
changeretat();
}
public boolean Isinit() {
message = "";
getChauffeur_list();
if (!(chauffeur_list.isEmpty())) {
chauffeur_list = (List<Chauffeur>) getChauffeur_list();
chauffeur = (Chauffeur) chauffeur_list.get(0);
}
etat = true;
invetat = !etat;
return init;
}
public void create() {
if (nouveau) {
try {
this.chauffeurService.save(chauffeur);
message = mess_insert_true;
style_message = "valid message";
} catch (Exception hx) {
hx.printStackTrace();
message = mess_op_false;
style_message = "err_message";
}
} else {
try {
this.chauffeurService.modify(chauffeur);
message = mess_modif_true;
style_message = "valid message";
} catch (Exception hx) {
hx.printStackTrace();
message = mess_op_false;
style_message = "err_message";
}
}
changeretat();
}
public void modifierligne() {
this.chauffeur = (Chauffeur) dataTable.getRowData();
message = "";
nouveau = false;
changeretat();
}
public void modifier() {
message = "";
nouveau = false;
changeretat();
}
public void Supprimer() {
try {
this.chauffeurService.delete(chauffeur);
message = mess_del_true;
style_message = "valid message";
if (index > 0) {
index--;
}
chauffeur_list = (List<Chauffeur>) getChauffeur_list();
if (!(chauffeur_list.isEmpty())) {
chauffeur = (Chauffeur) chauffeur_list.get(index);
} else {
viderchamps();
changeretat();
}
} catch (Exception hx) {
hx.printStackTrace();
message = mess_op_false;
}
}
public Chauffeur getChauffeur() {
return chauffeur;
}
public void setChauffeur(Chauffeur chauffeur) {
this.chauffeur = chauffeur;
}
public ChauffeurService getChauffeurService() {
return chauffeurService;
}
public void setChauffeurService(ChauffeurService chauffeurService) {
this.chauffeurService = chauffeurService;
}
public boolean isInit() {
return init;
}
public void setInit(boolean init) {
this.init = init;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isNouveau() {
return nouveau;
}
public void setNouveau(boolean nouveau) {
this.nouveau = nouveau;
}
public UIDataTable getDataTable() {
return dataTable;
}
public void setDataTable(UIDataTable dataTable) {
this.dataTable = dataTable;
}
public List<Chauffeur> getChauffeur_list() {
return chauffeur_list;
}
public void setChauffeur_list(List<Chauffeur> chauffeur_list) {
this.chauffeur_list = chauffeur_list;
}
} |
Voilà ma JSP
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
| <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK rel="stylesheet" type="text/css" href="commun_styles.css" />
<title>Service</title>
</head>
<body>
<h:form id="mainchauffeur">
<a4j:include viewId="Entete.jsp"/>
<a4j:include viewId="menu.jsp"/>
<h:inputHidden value="#{chauffeurBean.init}" />
<rich:spacer height="50px" />
<center>
<rich:tabPanel style="width:500px;">
<rich:tab label="Chauffeur">
<h:outputText id="mesinfo" value="#{chauffeurBean.message}"
style="message_valide" />
<h:panelGrid width="60%" columns="1">
<rich:panel id="tablepanel" header="liste Chauffeur">
<rich:dataTable binding="#{chauffeurBean.dataTable}"
value="#{chauffeurBean.chauffeur_list}" var="chauffeur"
onRowMouseOver="this.style.backgroundColor='#B5CEFD'"
onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
onRowClick="this.style.backgroundColor='#F1F1F1'" width="450px" rows="8" id="tab">
<rich:columns id="idChf" width="60px">
<f:facet name="header">
<h:outputText value="Code"></h:outputText>
</f:facet>
<h:outputText value="#{chauffeur.idChf}"></h:outputText>
</rich:columns>
<rich:columns id="nomChf" width="60px">
<f:facet name="header">
<h:outputText value="nomchauff"></h:outputText>
</f:facet>
<h:outputText value="#{chauffeur.nomChf}"></h:outputText>
</rich:columns>
<rich:columns style="text-align:center" width="70px">
<f:facet name="header">
<h:outputText value="Modifier"></h:outputText>
</f:facet>
<a4j:commandLink action="#{chauffeurBean.modifierligne}">
<h:graphicImage style="border:0" url="/images/pensel.png"></h:graphicImage>
</a4j:commandLink>
</rich:columns>
<rich:columns style="text-align:center" width="70px">
<f:facet name="header">
<h:outputText value="Supprimer"></h:outputText>
</f:facet>
<a4j:commandLink action="#{chauffeurBean.Supprimer}">
<h:graphicImage style="border:0" url="/images/pensel.png"></h:graphicImage>
</a4j:commandLink>
</rich:columns>
<f:facet name="footer">
<rich:datascroller />
</f:facet>
</rich:dataTable>
</rich:panel>
<rich:panel id="panelinfo" header="information générale">
<h:panelGrid columns="2" width="350">
<h:outputText value=" code chauffeur : " />
<h:inputText disabled="#{chauffeurBean.etat}" id="idChf"
value="#{chauffeurBean.chauffeur.idChf} " size="25"
maxlength="30" />
<h:outputText value=" nom de chauffeur : " />
<h:inputText disabled="#{chauffeurBean.etat}" id="nom"
value="#{chauffeurBean.chauffeur.nomChf} " size="25"
maxlength="30" />
<h:outputText value=" prénom chauffeur : " />
<h:inputText disabled="#{chauffeurBean.etat}" id="prénom"
value="#{chauffeurBean.chauffeur.prenomChf} " size="25"
maxlength="30" />
<h:outputText value=" Adresse Chauffeur : " />
<h:inputText disabled="#{chauffeurBean.etat}" id="adresse"
value="#{chauffeurBean.chauffeur.adresseChf} " size="25"
maxlength="30" />
</h:panelGrid>
</rich:panel>
</h:panelGrid>
<h:panelGrid id="crudpanel" columns="5">
<a4j:commandButton id="nouvchauff" ajaxSingle="true" disabled="#{chauffeurBean.invetat}"
reRender="infomsg,tablepanel,panelinfo,crud_panel" value="nouveau" action="#{chauffeurBean.viderchamps}" style="width:85px"/>
<a4j:commandButton id="modifchauff" ajaxSingle="true" disabled="#{chauffeurBean.invetat}"
reRender="infomsg,tablepanel,panelinfo,crud_panel" value="modifier" action="#{chauffeurBean.modifier}" style="width:85px"/>
<a4j:commandButton id="suppchauff" ajaxSingle="true" disabled="#{chauffeurBean.invetat}"
reRender="infomsg,tablepanel,panelinfo,crud_panel" value="Supprimer" action="#{chauffeurBean.Supprimer}" style="width:85px"/>
<a4j:commandButton id="validechauff" ajaxSingle="true" disabled="#{chauffeurBean.invetat}"
reRender="infomsg,tablepanel,panelinfo,crud_panel" value="creer" action="#{chauffeurBean.create}" style="width:85px"/>
<a4j:commandButton id="annulerchauf" ajaxSingle="true" disabled="#{chauffeurBean.invetat}"
reRender="infomsg,tablepanel,panelinfo,crud_panel" value="annuler" action="#{chauffeurBean.annuler}" style="width:85px"/>
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
</center>
</h:form>
</html>
</f:view> |
Voilà l'interface du Service
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| package org.wisetech.geoloc.Interface;
import java.util.List;
import org.wisetech.geoloc.model.Chauffeur;
public interface ChauffeurService {
public List<Chauffeur> findAll();
public void save(Chauffeur chauffeur);
public void modify(Chauffeur chauffeur);
public void delete(Chauffeur chauffeur);
} |
Pièce jointe 81801
Quelqu'un saurait-il m'indiquer ce qui ne va pas ?
Merci d'avance pour votre aide.