Jean-Francois Leveque

Compile (WIP sur updateUser.xhtml et le reste de la transition User)

...@@ -8,4 +8,8 @@ public interface UserService { ...@@ -8,4 +8,8 @@ public interface UserService {
8 void addUser(User user); 8 void addUser(User user);
9 9
10 List<User> getAllUsers(); 10 List<User> getAllUsers();
11 +
12 + User findUserById(int id);
13 +
14 + void updateUser(User user);
11 } 15 }
......
...@@ -10,13 +10,21 @@ import java.util.List; ...@@ -10,13 +10,21 @@ import java.util.List;
10 @Stateless 10 @Stateless
11 public class UserServiceSpring implements UserService { 11 public class UserServiceSpring implements UserService {
12 @Inject 12 @Inject
13 - UserRepository repository; 13 + UserRepository userRepository;
14 14
15 public void addUser(User user) { 15 public void addUser(User user) {
16 - repository.save(user); 16 + userRepository.save(user);
17 } 17 }
18 18
19 public List<User> getAllUsers() { 19 public List<User> getAllUsers() {
20 - return repository.findAll(); 20 + return userRepository.findAll();
21 } 21 }
22 -} 22 +
23 + public User findUserById(int id) {
24 + return userRepository.findOne(new Integer(id));
25 + }
26 +
27 + public void updateUser(User user) {
28 + userRepository.save(user);
29 + }
30 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,9 +4,13 @@ import org.legrog.application.UserService; ...@@ -4,9 +4,13 @@ import org.legrog.application.UserService;
4 import org.legrog.entities.User; 4 import org.legrog.entities.User;
5 5
6 import javax.annotation.PostConstruct; 6 import javax.annotation.PostConstruct;
7 +import javax.enterprise.context.RequestScoped;
7 import javax.inject.Inject; 8 import javax.inject.Inject;
9 +import javax.inject.Named;
8 import java.util.List; 10 import java.util.List;
9 11
12 +@Named
13 +@RequestScoped
10 public class ListUsersBean { 14 public class ListUsersBean {
11 @Inject 15 @Inject
12 private UserService userService; 16 private UserService userService;
......
...@@ -65,11 +65,43 @@ public class UpdateUserBean { ...@@ -65,11 +65,43 @@ public class UpdateUserBean {
65 public String add() 65 public String add()
66 { 66 {
67 User user = new User(); 67 User user = new User();
68 + user.setActivated(activated);
69 + user.setAnonymous(anonymous);
70 + user.setAttributes(userAttributes);
71 + user.setCriticProvider(criticProvider);
72 + user.setDisplayNameMask(displayNameMask);
73 + user.setEmail(email);
74 + user.setFirstName(firstName);
75 + user.setLastName(lastName);
76 + user.setNickName(nickName);
77 + user.setPassword(password);
78 + user.setPresentation(presentation);
79 + user.setRoles(roles);
68 user.setUsername(username); 80 user.setUsername(username);
81 + user.setVisible(visible);
69 userService.addUser(user); 82 userService.addUser(user);
70 return "success"; 83 return "success";
71 } 84 }
72 85
86 + public String update() {
87 + User user = userService.findUserById(userId);
88 + user.setActivated(activated);
89 + user.setAnonymous(anonymous);
90 + user.setAttributes(userAttributes);
91 + user.setCriticProvider(criticProvider);
92 + user.setDisplayNameMask(displayNameMask);
93 + user.setEmail(email);
94 + user.setFirstName(firstName);
95 + user.setLastName(lastName);
96 + user.setNickName(nickName);
97 + user.setPassword(password);
98 + user.setPresentation(presentation);
99 + user.setRoles(roles);
100 + user.setUsername(username);
101 + user.setVisible(visible);
102 + userService.updateUser(user);
103 + return "success";
104 + }
73 public String getFirstName() { 105 public String getFirstName() {
74 return firstName; 106 return firstName;
75 } 107 }
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
33 </navigation-case> 33 </navigation-case>
34 <navigation-case> 34 <navigation-case>
35 <from-outcome>addUser</from-outcome> 35 <from-outcome>addUser</from-outcome>
36 - <to-view-id>/addUser_short.xhtml</to-view-id> 36 + <to-view-id>/updateUser.xhtml</to-view-id>
37 </navigation-case> 37 </navigation-case>
38 <navigation-case> 38 <navigation-case>
39 <from-outcome>listUsers</from-outcome> 39 <from-outcome>listUsers</from-outcome>
40 - <to-view-id>/listUsers_short.xhtml</to-view-id> 40 + <to-view-id>/listUsers.xhtml</to-view-id>
41 </navigation-case> 41 </navigation-case>
42 </navigation-rule> 42 </navigation-rule>
43 43
...@@ -72,4 +72,19 @@ ...@@ -72,4 +72,19 @@
72 <to-view-id>/book.xhtml</to-view-id> 72 <to-view-id>/book.xhtml</to-view-id>
73 </navigation-case> 73 </navigation-case>
74 </navigation-rule> 74 </navigation-rule>
75 +
76 + <navigation-rule>
77 + <from-view-id>/updateUser.xhtml</from-view-id>
78 + <navigation-case>
79 + <from-outcome>cancel</from-outcome>
80 + <to-view-id>/listUsers.xhtml</to-view-id>
81 + </navigation-case>
82 + </navigation-rule>
83 + <navigation-rule>
84 + <from-view-id>/listUsers.xhtml</from-view-id>
85 + <navigation-case>
86 + <from-outcome>add</from-outcome>
87 + <to-view-id>/updateUser.xhtml</to-view-id>
88 + </navigation-case>
89 + </navigation-rule>
75 </faces-config> 90 </faces-config>
...\ No newline at end of file ...\ No newline at end of file
......
1 <?xml version="1.0" encoding="ISO-8859-1"?> 1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 -<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 -<ui:composition xmlns="http://www.w3.org/1999/xhtml" 3 +<html xmlns="http://www.w3.org/1999/xhtml"
4 xmlns:ui="http://java.sun.com/jsf/facelets" 4 xmlns:ui="http://java.sun.com/jsf/facelets"
5 xmlns:h="http://java.sun.com/jsf/html" 5 xmlns:h="http://java.sun.com/jsf/html"
6 xmlns:f="http://java.sun.com/jsf/core" 6 xmlns:f="http://java.sun.com/jsf/core"
7 - xmlns:p="http://primefaces.org/ui" 7 + xmlns:p="http://primefaces.org/ui">
8 - template="#{theme.template}"> 8 +<!-- <ui:composition xmlns="http://www.w3.org/1999/xhtml"
9 + xmlns:ui="http://java.sun.com/jsf/facelets"
10 + xmlns:h="http://java.sun.com/jsf/html"
11 + xmlns:f="http://java.sun.com/jsf/core"
12 + xmlns:p="http://primefaces.org/ui"
13 + template="#{theme.template}">-->
9 14
10 <!-- content --> 15 <!-- content -->
11 - <ui:define name="content"> 16 + <!--<ui:define name="content">-->
12 - 17 +<body>
13 <h2>Liste des utilisateurs</h2> 18 <h2>Liste des utilisateurs</h2>
14 19
15 <p> 20 <p>
...@@ -21,28 +26,24 @@ ...@@ -21,28 +26,24 @@
21 </p> 26 </p>
22 27
23 <h:form> 28 <h:form>
24 - <div id="search" style="text-align:center;"> 29 + <!-- TODO Grer les recherches -->
25 - <h:panelGrid columns="3" styleClass="half">
26 - <h:outputLabel for="searchString" value="Filtre" styleClass="req"/>
27 - <h:inputText id="searchString" value="#{userListMgr.searchString}" styleClass="req"/>
28 - <h:commandButton id="find" value="OK" action="#{userListMgr.find}" styleClass="lanceReq"><!--<s:defaultAction/>--></h:commandButton>
29 - </h:panelGrid>
30 - <h:outputText value="Pas d'lment respectant ce critre dans la base"
31 - rendered="#{elementList.rowCount==0}"/>
32 - </div>
33 30
34 <h:messages globalOnly="true" errorClass="errorMsg" infoClass="infoMsg"/> 31 <h:messages globalOnly="true" errorClass="errorMsg" infoClass="infoMsg"/>
35 32
36 <div id="listElements"> 33 <div id="listElements">
37 34
38 - <h:commandLink styleClass="fRight acLink" action="#{userListMgr.goToCreate('user')}" > 35 + <h:commandLink styleClass="fRight acLink" action="add" rendered="#{not empty listUsersBean.users}" >
39 <img src="/images/structure/vide.gif" class="icAddC" alt="" title="Crer un nouvel utilisateur" /> 36 <img src="/images/structure/vide.gif" class="icAddC" alt="" title="Crer un nouvel utilisateur" />
40 Nouvel Utilisateur 37 Nouvel Utilisateur
41 </h:commandLink> 38 </h:commandLink>
42 39
43 - <p:dataTable id="tableElements" rendered="#{elementList.rowCount>0}" 40 + <p:dataTable id="tableElements" rendered="#{not empty listUsersBean.users}"
44 - var="user" value="#{elementList}" rows="#{userListMgr.pageSize}" 41 + var="user" value="#{listUsersBean.users}"
45 styleClass="results" rowClasses="altRichRow,altRow"> 42 styleClass="results" rowClasses="altRichRow,altRow">
43 + <!-- TODO Grer la pagination -->
44 +<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.users.size>0}"
45 + var="user" value="#{listUsersBean.users}" rows="#{userListMgr.pageSize}"
46 + styleClass="results" rowClasses="altRichRow,altRow">-->
46 <f:facet name="header"> 47 <f:facet name="header">
47 <p:dataScroller for="tableElements" 48 <p:dataScroller for="tableElements"
48 stepControls="auto" boundaryControls="auto" fastControls="auto"> 49 stepControls="auto" boundaryControls="auto" fastControls="auto">
...@@ -53,27 +54,29 @@ ...@@ -53,27 +54,29 @@
53 <f:facet name="pages" >&#160;</f:facet> 54 <f:facet name="pages" >&#160;</f:facet>
54 </p:dataScroller> 55 </p:dataScroller>
55 </f:facet> 56 </f:facet>
56 - <p:column rendered="#{s:hasRole('ADMINISTRATEUR')}"> 57 + <!-- TODO Grer les droits des actions -->
57 - <h:commandLink id="delete" onclick="return confirm('Voulez vous vraiment supprimer cet lment ?');" action="#{userListMgr.delete}"> 58 + <p:column>
59 +<!-- <h:commandLink id="delete" onclick="return confirm('Voulez vous vraiment supprimer cet lment ?');" action="#{userListMgr.delete}">
58 <img src="/images/structure/vide.gif" class="icDel" alt="" title="Effacer" /> 60 <img src="/images/structure/vide.gif" class="icDel" alt="" title="Effacer" />
59 - </h:commandLink> 61 + </h:commandLink>-->
60 </p:column> 62 </p:column>
61 - <p:column rendered="#{s:hasRole('ADMINISTRATEUR')}"> 63 + <p:column>
62 - <h:commandLink action="#{userListMgr.goToUpdate('user', user.pk)}"> 64 + <!--<h:commandLink action="#{userListMgr.goToUpdate('user', user.userId)}">
63 <img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" /> 65 <img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" />
64 - </h:commandLink> 66 + </h:commandLink>-->
65 </p:column> 67 </p:column>
66 <p:column styleClass="third" sortBy="#{user.username}"> 68 <p:column styleClass="third" sortBy="#{user.username}">
67 <f:facet name="header">Identifiant</f:facet> 69 <f:facet name="header">Identifiant</f:facet>
68 - <h:outputLink value="#{user.traceable.urlRewrite}"> 70 + <!-- TODO Dcider de l'avenir de traceable -->
71 +<!-- <h:outputLink value="#{user.traceable.urlRewrite}">-->
69 <h:outputText value="#{user.username}" /> 72 <h:outputText value="#{user.username}" />
70 - </h:outputLink> 73 +<!-- </h:outputLink>-->
71 </p:column> 74 </p:column>
72 <p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}"> 75 <p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}">
73 <f:facet name="header">Nom</f:facet> 76 <f:facet name="header">Nom</f:facet>
74 - <h:outputLink value="#{user.traceable.urlRewrite}"> 77 + <!--<h:outputLink value="#{user.traceable.urlRewrite}">-->
75 <h:outputText value="#{user.firstName} #{user.lastName}" /> 78 <h:outputText value="#{user.firstName} #{user.lastName}" />
76 - </h:outputLink> 79 + <!--</h:outputLink>-->
77 </p:column> 80 </p:column>
78 <p:column styleClass="third" sortBy="#{user.email}"> 81 <p:column styleClass="third" sortBy="#{user.email}">
79 <f:facet name="header">Email</f:facet> 82 <f:facet name="header">Email</f:facet>
...@@ -85,24 +88,26 @@ ...@@ -85,24 +88,26 @@
85 <h:graphicImage value="/images/structure/dRouge.gif" rendered="#{not user.activated}" title="Utilisateur non enregistr" /> 88 <h:graphicImage value="/images/structure/dRouge.gif" rendered="#{not user.activated}" title="Utilisateur non enregistr" />
86 </p:column> 89 </p:column>
87 <f:facet name="footer"> 90 <f:facet name="footer">
88 - <h:commandLink action="#{userListMgr.goToCreate('user')}" value="Crer un nouvel utilisateur" > 91 + <h:commandLink action="add" value="Crer un nouvel utilisateur" >
89 </h:commandLink> 92 </h:commandLink>
90 </f:facet> 93 </f:facet>
91 </p:dataTable> 94 </p:dataTable>
95 + </div>
92 <p> 96 <p>
93 - <h:commandLink action="#{userListMgr.goToCreate('user')}" value="Crer un nouvel utilisateur" 97 + <h:commandLink action="add" value="Crer un nouvel utilisateur"
94 - rendered="#{elementList.rowCount==0}"> 98 + rendered="#{empty listUsersBean.users}">
95 </h:commandLink> 99 </h:commandLink>
96 </p> 100 </p>
97 - </div>
98 </h:form> 101 </h:form>
99 - 102 +</body>
100 - </ui:define> 103 + <!--</ui:define>-->
101 104
102 <!-- sidebars --> 105 <!-- sidebars -->
106 +<!--
103 <ui:define name="sidebar"> 107 <ui:define name="sidebar">
104 <ui:include src="/includes/top-sidebar-admin.include"/> 108 <ui:include src="/includes/top-sidebar-admin.include"/>
105 109
106 </ui:define> 110 </ui:define>
107 -
108 -</ui:composition>
...\ No newline at end of file ...\ No newline at end of file
111 + -->
112 +</html>
113 +<!--</ui:composition>-->
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
11 <h:outputText value="Menu principal"/> 11 <h:outputText value="Menu principal"/>
12 </h:commandLink> 12 </h:commandLink>
13 </h:form> 13 </h:form>
14 - <f:metadata>
15 - <f:event type="preRenderView" listener="#{updateUserBean.onload}" />
16 - </f:metadata>
17 <ul> 14 <ul>
18 - <ui:repeat value="#{updateUserBean.users}" var="user"> 15 + <ui:repeat value="#{listUsersBean.users}" var="user">
19 <li>#{user.username}</li> 16 <li>#{user.username}</li>
20 </ui:repeat> 17 </ui:repeat>
21 </ul> 18 </ul>
......
1 <?xml version="1.0" encoding="ISO-8859-1"?> 1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 -<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 -<ui:composition xmlns="http://www.w3.org/1999/xhtml" 3 + <html xmlns="http://www.w3.org/1999/xhtml"
4 + xmlns:ui="http://java.sun.com/jsf/facelets"
5 + xmlns:h="http://java.sun.com/jsf/html"
6 + xmlns:f="http://java.sun.com/jsf/core"
7 + xmlns:p="http://primefaces.org/ui">
8 +<!--<ui:composition xmlns="http://www.w3.org/1999/xhtml"
4 xmlns:ui="http://java.sun.com/jsf/facelets" 9 xmlns:ui="http://java.sun.com/jsf/facelets"
5 xmlns:h="http://java.sun.com/jsf/html" 10 xmlns:h="http://java.sun.com/jsf/html"
6 xmlns:f="http://java.sun.com/jsf/core" 11 xmlns:f="http://java.sun.com/jsf/core"
...@@ -8,10 +13,11 @@ ...@@ -8,10 +13,11 @@
8 xmlns:a4j="http://richfaces.org/a4j" 13 xmlns:a4j="http://richfaces.org/a4j"
9 xmlns:rich="http://richfaces.org/rich" 14 xmlns:rich="http://richfaces.org/rich"
10 xmlns:p="http://primefaces.org/ui" 15 xmlns:p="http://primefaces.org/ui"
11 - template="#{theme.template}"> 16 + template="#{theme.template}">-->
12 17
13 <!-- content --> 18 <!-- content -->
14 - <ui:define name="content"> 19 +<!-- <ui:define name="content">-->
20 +<body>
15 <h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/> 21 <h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/>
16 <h:outputText value="Modification " rendered="#{not empty(updateUserBean.userId)}"/>d'un utilisateur</h2> 22 <h:outputText value="Modification " rendered="#{not empty(updateUserBean.userId)}"/>d'un utilisateur</h2>
17 23
...@@ -65,7 +71,7 @@ ...@@ -65,7 +71,7 @@
65 </tr> 71 </tr>
66 <tr> 72 <tr>
67 <td><h:outputLabel for="email">Adresse email *</h:outputLabel></td> 73 <td><h:outputLabel for="email">Adresse email *</h:outputLabel></td>
68 - <td><h:inputText id="email" value="#{updateUserBean.email}" required="true" style="width: 175px;" maxlength="100"><f:validator validatorId="validateEmail"/></h:inputText></td> 74 + <td><h:inputText id="email" value="#{updateUserBean.email}" required="true" style="width: 175px;" maxlength="100"><!--<f:validator validatorId="validateEmail"/>--></h:inputText></td>
69 <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="email"/></td> 75 <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="email"/></td>
70 </tr> 76 </tr>
71 <tr> 77 <tr>
...@@ -89,10 +95,12 @@ ...@@ -89,10 +95,12 @@
89 </tr> 95 </tr>
90 <tr> 96 <tr>
91 <td valign="top"> 97 <td valign="top">
98 + <!--
92 <h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/> 99 <h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/>
93 <h:message styleClass="errorMsg" for="text"/> 100 <h:message styleClass="errorMsg" for="text"/>
101 + -->
94 </td> 102 </td>
95 - <td colspan="2"><rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/></td> 103 + <td colspan="2"><!--<rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/>--></td>
96 </tr> 104 </tr>
97 <ui:fragment rendered="#{not empty(updateUserBean.userId)}"> 105 <ui:fragment rendered="#{not empty(updateUserBean.userId)}">
98 <tr> 106 <tr>
...@@ -129,8 +137,9 @@ ...@@ -129,8 +137,9 @@
129 </tr> 137 </tr>
130 <tr> 138 <tr>
131 <td colspan="3" class="taCenter"> 139 <td colspan="3" class="taCenter">
132 - <h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}"/>&#160; 140 + <h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}" rendered="#{not empty(updateUserBean.userId)}"/>&#160;
133 - <h:commandButton id="cancel" value="Annuler" action="#{userMgr.cancel}" immediate="true"> 141 + <h:commandButton id="add" value="Crer" action="#{updateUserBean.add}" rendered="#{empty(updateUserBean.userId)}"/>&#160;
142 + <h:commandButton id="cancel" value="Annuler" action="cancel">
134 </h:commandButton> 143 </h:commandButton>
135 </td> 144 </td>
136 </tr> 145 </tr>
...@@ -178,7 +187,7 @@ ...@@ -178,7 +187,7 @@
178 <!--</s:validateAll>--> 187 <!--</s:validateAll>-->
179 </h:form> 188 </h:form>
180 </p:panel> 189 </p:panel>
181 - 190 +<!--
182 <h:form rendered="#{not empty(updateUserBean.userId)}"> 191 <h:form rendered="#{not empty(updateUserBean.userId)}">
183 <h3>Dlgations</h3> 192 <h3>Dlgations</h3>
184 <p> 193 <p>
...@@ -256,14 +265,16 @@ ...@@ -256,14 +265,16 @@
256 </p> 265 </p>
257 </p:panel> 266 </p:panel>
258 </h:form> 267 </h:form>
259 - 268 +-->
260 - </ui:define> 269 +<!-- </ui:define>-->
261 270
262 <!-- sidebars --> 271 <!-- sidebars -->
272 +<!--
263 <ui:define name="sidebar"> 273 <ui:define name="sidebar">
264 <ui:include src="/includes/top-sidebar-admin.include"/> 274 <ui:include src="/includes/top-sidebar-admin.include"/>
265 275
266 - </ui:define> 276 + </ui:define>-->
267 - 277 +</body>
268 -</ui:composition> 278 +</html>
279 +<!--</ui:composition>-->
269 280
......