A voir également:
- Problem lors de depoiement d'une application JEE
- Application mobile - Guide
- Nommez une application d'appel vidéo ou de visioconférence - Guide
- Désinstaller une application sur pc - Guide
- Application gps sans internet - Guide
- Comment supprimer une application préinstallée sur android - Guide
3 réponses
est-ce qu'il est possible de voir ta class
com.model.User et ton fichier de conf applicationContext.xml?
ou sinon, il semble que tu veuilles caster un tableau []
en arraylist ce qui n'est pas permis.
com.model.User et ton fichier de conf applicationContext.xml?
ou sinon, il semble que tu veuilles caster un tableau []
en arraylist ce qui n'est pas permis.
bien sur ,
voici ma classe user:
package com.model;
// default package
// Generated 12 mai 2014 13:38:22 by Hibernate Tools 3.4.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* User generated by hbm2java
*/
@Entity
@Table(name = "user", catalog = "fac_medecine")
public class User implements java.io.Serializable {
private Integer id;
private String login;
private String password;
public User() {
}
public User(String login, String password) {
this.login = login;
this.password = password;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "login", nullable = false, length = 50)
public String getLogin() {
return this.login;
}
public void setLogin(String login) {
this.login = login;
}
@Column(name = "password", nullable = false, length = 50)
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}
et voici fichier de config applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Data Source Declaration -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url">
<value>jdbc:mysql://127.0.0.1:3306/projet?useUnicode=true&characterEncoding=UTF-8</value>
</property>
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
<!-- Session Factory Declaration -->
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.model.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- Transaction Manager is defined -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
<!-- User Service Declaration -->
<bean id="indexService" class="com.service.IndexService">
<property name="indexDao" ref="indexDao" />
</bean>
<bean id="genericService" class="com.service.GenericService">
<property name="genericDao" ref="genericDao" />
</bean>
<!-- User DAO Declaration -->
<bean id="indexDao" class="com.dao.IndexDao">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
<bean id="genericDao" class="com.dao.GenericDao">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>
et encore ceci ma classe bean
package com.bean;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.component.datatable.DataTable;
import com.model.User;
import com.service.IGenericService;
import com.service.IIndexService;
import com.utils.ClassUtils;
@ManagedBean(name="userBean")
@SessionScoped
public class UserBean {
@ManagedProperty(value="#{genericService}")
IGenericService genericService;
//private List<User> users=new ArrayList<User>();
private DataTable usersTable;
private User user = new User();
private User addUser = new User();
private boolean connected = false;
private List<User> filteredCars;
@ManagedProperty(value="#{indexService}")
IIndexService indexService;
public String connect(){
// ClassUtils classUtils=new ClassUtils();
System.out.println(user.getLogin());
user.setPassword(ClassUtils.getEncodedPassword(user.getPassword()));
System.out.println(user.getPassword());
user = indexService.connect(user);
if(user!=null){
connected = true;
user.setPassword(null);
return ClassUtils.CONNECT;
}
else{
ClassUtils.messageError(FacesMessage.SEVERITY_INFO,"Error connexion!","",null);
user=new User();
return null;
}
}
/*
// pour affichier la liste des users
public String displayUsers() {
System.out.print("dans display users");
List<Object> objects = genericService.getAllObject(User.class);
users = new ArrayList<User>();
for(Object o : objects){
users.add((User) o);
}
//zoneDisplayBooks = true
return ClassUtils.LISTEUSERS;
}
//pour ajouter un user
public void saveUser(ActionEvent actionEvent){
if(addUser.getId()==0)
genericService.saveObject(addUser);
else
genericService.updateObject(addUser);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur Bien Ajouter"));
addUser=new User();
//return null;
}
//action de navigation
public String ajoutMembre(){
System.out.print("voila");
return ClassUtils.AJOUTERMEMBRE;
}
public String listeUsers(){
System.out.print("voila");
return ClassUtils.LISTEUSERS;
}
public void test(){
System.out.print("test Action listenaire");
}
//edit popop pour la modification
public void editEvent(int id) {
user=(User) genericService.getObject(User.class,id);
}
//pour la mise a jour
public void edition(ActionEvent e){
genericService.updateObject(user);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur mise à jour"));
int i=0;
for (User s : users) {
if (s.getId()==user.getId())
break;
i++;
}
users.set(i, user);
}
//pour la suppression
public void delet(User o) {
genericService.deleteObject(o);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur Supprimer"));
int i=0;
for (User s : users) {
if (s.getId()==user.getId())
break;
i++;
}
users.remove(i);
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setIndexService(IIndexService indexService) {
this.indexService = indexService;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public IIndexService getIndexService() {
return indexService;
}
public IGenericService getGenericService() {
return genericService;
}
public void setGenericService(IGenericService genericService) {
this.genericService = genericService;
}
public User getAddUser() {
return addUser;
}
public void setAddUser(User addUser) {
this.addUser = addUser;
}
public List<User> getUsers() {
System.out.print("dans get users");
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public DataTable getUsersTable() {
return usersTable;
}
public void setUsersTable(DataTable usersTable) {
this.usersTable = usersTable;
}
public List<User> getFilteredCars() {
this.displayUsers();
return filteredCars;
}
public void setFilteredCars(List<User> filteredCars) {
this.filteredCars = filteredCars;
}
*/
}
voici ma classe user:
package com.model;
// default package
// Generated 12 mai 2014 13:38:22 by Hibernate Tools 3.4.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* User generated by hbm2java
*/
@Entity
@Table(name = "user", catalog = "fac_medecine")
public class User implements java.io.Serializable {
private Integer id;
private String login;
private String password;
public User() {
}
public User(String login, String password) {
this.login = login;
this.password = password;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "login", nullable = false, length = 50)
public String getLogin() {
return this.login;
}
public void setLogin(String login) {
this.login = login;
}
@Column(name = "password", nullable = false, length = 50)
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}
et voici fichier de config applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Data Source Declaration -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url">
<value>jdbc:mysql://127.0.0.1:3306/projet?useUnicode=true&characterEncoding=UTF-8</value>
</property>
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
<!-- Session Factory Declaration -->
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.model.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- Transaction Manager is defined -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
<!-- User Service Declaration -->
<bean id="indexService" class="com.service.IndexService">
<property name="indexDao" ref="indexDao" />
</bean>
<bean id="genericService" class="com.service.GenericService">
<property name="genericDao" ref="genericDao" />
</bean>
<!-- User DAO Declaration -->
<bean id="indexDao" class="com.dao.IndexDao">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
<bean id="genericDao" class="com.dao.GenericDao">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>
et encore ceci ma classe bean
package com.bean;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.component.datatable.DataTable;
import com.model.User;
import com.service.IGenericService;
import com.service.IIndexService;
import com.utils.ClassUtils;
@ManagedBean(name="userBean")
@SessionScoped
public class UserBean {
@ManagedProperty(value="#{genericService}")
IGenericService genericService;
//private List<User> users=new ArrayList<User>();
private DataTable usersTable;
private User user = new User();
private User addUser = new User();
private boolean connected = false;
private List<User> filteredCars;
@ManagedProperty(value="#{indexService}")
IIndexService indexService;
public String connect(){
// ClassUtils classUtils=new ClassUtils();
System.out.println(user.getLogin());
user.setPassword(ClassUtils.getEncodedPassword(user.getPassword()));
System.out.println(user.getPassword());
user = indexService.connect(user);
if(user!=null){
connected = true;
user.setPassword(null);
return ClassUtils.CONNECT;
}
else{
ClassUtils.messageError(FacesMessage.SEVERITY_INFO,"Error connexion!","",null);
user=new User();
return null;
}
}
/*
// pour affichier la liste des users
public String displayUsers() {
System.out.print("dans display users");
List<Object> objects = genericService.getAllObject(User.class);
users = new ArrayList<User>();
for(Object o : objects){
users.add((User) o);
}
//zoneDisplayBooks = true
return ClassUtils.LISTEUSERS;
}
//pour ajouter un user
public void saveUser(ActionEvent actionEvent){
if(addUser.getId()==0)
genericService.saveObject(addUser);
else
genericService.updateObject(addUser);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur Bien Ajouter"));
addUser=new User();
//return null;
}
//action de navigation
public String ajoutMembre(){
System.out.print("voila");
return ClassUtils.AJOUTERMEMBRE;
}
public String listeUsers(){
System.out.print("voila");
return ClassUtils.LISTEUSERS;
}
public void test(){
System.out.print("test Action listenaire");
}
//edit popop pour la modification
public void editEvent(int id) {
user=(User) genericService.getObject(User.class,id);
}
//pour la mise a jour
public void edition(ActionEvent e){
genericService.updateObject(user);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur mise à jour"));
int i=0;
for (User s : users) {
if (s.getId()==user.getId())
break;
i++;
}
users.set(i, user);
}
//pour la suppression
public void delet(User o) {
genericService.deleteObject(o);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Utilisateur Supprimer"));
int i=0;
for (User s : users) {
if (s.getId()==user.getId())
break;
i++;
}
users.remove(i);
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setIndexService(IIndexService indexService) {
this.indexService = indexService;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public IIndexService getIndexService() {
return indexService;
}
public IGenericService getGenericService() {
return genericService;
}
public void setGenericService(IGenericService genericService) {
this.genericService = genericService;
}
public User getAddUser() {
return addUser;
}
public void setAddUser(User addUser) {
this.addUser = addUser;
}
public List<User> getUsers() {
System.out.print("dans get users");
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public DataTable getUsersTable() {
return usersTable;
}
public void setUsersTable(DataTable usersTable) {
this.usersTable = usersTable;
}
public List<User> getFilteredCars() {
this.displayUsers();
return filteredCars;
}
public void setFilteredCars(List<User> filteredCars) {
this.filteredCars = filteredCars;
}
*/
}