Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. My managed bean:
  2.  
  3. package web;
  4. import java.util.List;
  5.  
  6.  
  7. import javax.annotation.PostConstruct;
  8. import javax.enterprise.context.SessionScoped;
  9. import javax.faces.bean.ManagedBean;
  10. import mapping.*;
  11. import gestion.*;
  12.  
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Component;
  15.  
  16. @Component
  17. @ManagedBean(name="bean")
  18. @SessionScoped
  19. public class AjoutChamp {
  20. private Module module;
  21. private int m;
  22. private int etape;
  23. private int menu;
  24. private int TypeChamp;
  25. private int action;
  26. private int selecteur;
  27. private String valeur_selecteur;
  28. private String contexte;
  29. private String texte;
  30.  
  31. @Autowired
  32. private GestionEtape gEtape;
  33. @Autowired
  34. private GestionModule gModule;
  35.  
  36. private List<Module> listeModule;
  37.  
  38. @PostConstruct
  39. void init(){
  40. listeModule=gModule.selectAll();
  41. }
  42.  
  43. public int getM() {
  44. return m;
  45. }
  46. public void setM(int m) {
  47. this.m = m;
  48. }
  49. public List<Module> getListeModule() {
  50. return listeModule;
  51. }
  52. public void setListeModule(List<Module> listeModule) {
  53. this.listeModule = listeModule;
  54. }
  55.  
  56. public GestionEtape getgEtape() {
  57. return gEtape;
  58. }
  59. public void setgEtape(GestionEtape gEtape) {
  60. this.gEtape = gEtape;
  61. }
  62. public GestionModule getgModule() {
  63. return gModule;
  64. }
  65. public void setgModule(GestionModule gModule) {
  66. this.gModule = gModule;
  67. }
  68.  
  69. public Module getModule() {
  70. return module;
  71. }
  72. public void setModule(Module module) {
  73. this.module = module;
  74. }
  75. public int getEtape() {
  76. return etape;
  77. }
  78. public void setEtape(int etape) {
  79. this.etape = etape;
  80. }
  81. public int getMenu() {
  82. return menu;
  83. }
  84. public void setMenu(int menu) {
  85. this.menu = menu;
  86. }
  87. public int getTypeChamp() {
  88. return TypeChamp;
  89. }
  90. public void setTypeChamp(int typeChamp) {
  91. TypeChamp = typeChamp;
  92. }
  93. public int getAction() {
  94. return action;
  95. }
  96. public void setAction(int action) {
  97. this.action = action;
  98. }
  99. public int getSelecteur() {
  100. return selecteur;
  101. }
  102. public void setSelecteur(int selecteur) {
  103. this.selecteur = selecteur;
  104. }
  105. public String getValeur_selecteur() {
  106. return valeur_selecteur;
  107. }
  108. public void setValeur_selecteur(String valeur_selecteur) {
  109. this.valeur_selecteur = valeur_selecteur;
  110. }
  111. public String getContexte() {
  112. return contexte;
  113. }
  114. public void setContexte(String contexte) {
  115. this.contexte = contexte;
  116. }
  117. public String getTexte() {
  118. return texte;
  119. }
  120. public void setTexte(String texte) {
  121. this.texte = texte;
  122. }
  123.  
  124.  
  125. public AjoutChamp(){}
  126.  
  127. }
  128.  
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132. xmlns:aop="http://www.springframework.org/schema/aop"
  133. xmlns:tx="http://www.springframework.org/schema/tx"
  134. xmlns:context="http://www.springframework.org/schema/context"
  135. xsi:schemaLocation="
  136. http://www.springframework.org/schema/beans
  137. http://www.springframework.org/schema/beans/spring-beans.xsd
  138. http://www.springframework.org/schema/tx
  139. http://www.springframework.org/schema/tx/spring-tx.xsd
  140. http://www.springframework.org/schema/aop
  141. http://www.springframework.org/schema/aop/spring-aop.xsd
  142. http://www.springframework.org/schema/context
  143. http://www.springframework.org/schema/context/spring-context.xsd">
  144.  
  145. <context:component-scan base-package="web"></context:component-scan>
  146. <context:component-scan base-package="dao"></context:component-scan>
  147. <context:component-scan base-package="gestion"></context:component-scan>
  148.  
  149. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  150. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  151. <property name="url" value="jdbc:mysql://localhost:3306/yo?useSSL=false"/>
  152. <property name="username" value="root"/>
  153. <property name="password" value=""/>
  154. </bean>
  155.  
  156. <bean id="factory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  157. <property name="dataSource" ref="dataSource"/>
  158. <property name="hibernateProperties">
  159. <props>
  160. <prop
  161. key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
  162. <prop key="hibernate.show_sql">true</prop>
  163. </props>
  164. </property>
  165. <property name="packagesToScan">
  166. <list>
  167. <value>mapping</value>
  168. </list>
  169. </property>
  170. </bean>
  171.  
  172. <bean id="transactionManager"
  173. class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  174. <property name="sessionFactory" ref="factory"/>
  175. </bean>
  176. <tx:annotation-driven transaction-manager="transactionManager"/>
  177.  
  178. </beans>
  179.  
  180. xmlns:context="http://www.springframework.org/schema/context"
  181.  
  182. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
  183.  
  184. <beans xmlns="http://www.springframework.org/schema/beans"
  185. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  186. xmlns:aop="http://www.springframework.org/schema/aop"
  187. xmlns:tx="http://www.springframework.org/schema/tx"
  188. xmlns:context="http://www.springframework.org/schema/context"
  189. xsi:schemaLocation="
  190. http://www.springframework.org/schema/beans
  191. http://www.springframework.org/schema/beans/spring-beans.xsd
  192. http://www.springframework.org/schema/tx
  193. http://www.springframework.org/schema/tx/spring-tx.xsd
  194. http://www.springframework.org/schema/aop
  195. http://www.springframework.org/schema/aop/spring-aop.xsd
  196. http://www.springframework.org/schema/context
  197. http://www.springframework.org/schema/context/spring-context.xsd">
  198. ...
  199. </beans>
  200.  
  201. <dependency>
  202. <groupId>org.springframework</groupId>
  203. <artifactId>spring-context</artifactId>
  204. <version><!-- version of Spring context. --></version>
  205. </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement