Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2016-10-06 17:34:02 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9f63801a8803f4c678aad5ade4312decd0690729
9f63801a
1 parent
08a0358f
Compile (WIP sur updateUser.xhtml et le reste de la transition User)
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
136 additions
and
60 deletions
src/main/java/org/legrog/application/UserService.java
src/main/java/org/legrog/application/UserServiceSpring.java
src/main/java/org/legrog/presentation/ListUsersBean.java
src/main/java/org/legrog/presentation/UpdateUserBean.java
src/main/webapp/WEB-INF/faces-config.xml
src/main/webapp/listUsers.xhtml
src/main/webapp/listUsers_short.xhtml
src/main/webapp/updateUser.xhtml
src/main/java/org/legrog/application/UserService.java
View file @
9f63801
...
...
@@ -8,4 +8,8 @@ public interface UserService {
void
addUser
(
User
user
);
List
<
User
>
getAllUsers
();
User
findUserById
(
int
id
);
void
updateUser
(
User
user
);
}
...
...
src/main/java/org/legrog/application/UserServiceSpring.java
View file @
9f63801
...
...
@@ -10,13 +10,21 @@ import java.util.List;
@Stateless
public
class
UserServiceSpring
implements
UserService
{
@Inject
UserRepository
r
epository
;
UserRepository
userR
epository
;
public
void
addUser
(
User
user
)
{
r
epository
.
save
(
user
);
userR
epository
.
save
(
user
);
}
public
List
<
User
>
getAllUsers
()
{
return
r
epository
.
findAll
();
return
userR
epository
.
findAll
();
}
}
public
User
findUserById
(
int
id
)
{
return
userRepository
.
findOne
(
new
Integer
(
id
));
}
public
void
updateUser
(
User
user
)
{
userRepository
.
save
(
user
);
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/presentation/ListUsersBean.java
View file @
9f63801
...
...
@@ -4,9 +4,13 @@ import org.legrog.application.UserService;
import
org.legrog.entities.User
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.util.List
;
@Named
@RequestScoped
public
class
ListUsersBean
{
@Inject
private
UserService
userService
;
...
...
src/main/java/org/legrog/presentation/UpdateUserBean.java
View file @
9f63801
...
...
@@ -65,11 +65,43 @@ public class UpdateUserBean {
public
String
add
()
{
User
user
=
new
User
();
user
.
setActivated
(
activated
);
user
.
setAnonymous
(
anonymous
);
user
.
setAttributes
(
userAttributes
);
user
.
setCriticProvider
(
criticProvider
);
user
.
setDisplayNameMask
(
displayNameMask
);
user
.
setEmail
(
email
);
user
.
setFirstName
(
firstName
);
user
.
setLastName
(
lastName
);
user
.
setNickName
(
nickName
);
user
.
setPassword
(
password
);
user
.
setPresentation
(
presentation
);
user
.
setRoles
(
roles
);
user
.
setUsername
(
username
);
user
.
setVisible
(
visible
);
userService
.
addUser
(
user
);
return
"success"
;
}
public
String
update
()
{
User
user
=
userService
.
findUserById
(
userId
);
user
.
setActivated
(
activated
);
user
.
setAnonymous
(
anonymous
);
user
.
setAttributes
(
userAttributes
);
user
.
setCriticProvider
(
criticProvider
);
user
.
setDisplayNameMask
(
displayNameMask
);
user
.
setEmail
(
email
);
user
.
setFirstName
(
firstName
);
user
.
setLastName
(
lastName
);
user
.
setNickName
(
nickName
);
user
.
setPassword
(
password
);
user
.
setPresentation
(
presentation
);
user
.
setRoles
(
roles
);
user
.
setUsername
(
username
);
user
.
setVisible
(
visible
);
userService
.
updateUser
(
user
);
return
"success"
;
}
public
String
getFirstName
()
{
return
firstName
;
}
...
...
src/main/webapp/WEB-INF/faces-config.xml
View file @
9f63801
...
...
@@ -33,11 +33,11 @@
</navigation-case>
<navigation-case>
<from-outcome>
addUser
</from-outcome>
<to-view-id>
/
addUser_short
.xhtml
</to-view-id>
<to-view-id>
/
updateUser
.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
listUsers
</from-outcome>
<to-view-id>
/listUsers
_short
.xhtml
</to-view-id>
<to-view-id>
/listUsers.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
...
...
@@ -72,4 +72,19 @@
<to-view-id>
/book.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>
/updateUser.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
cancel
</from-outcome>
<to-view-id>
/listUsers.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>
/listUsers.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
add
</from-outcome>
<to-view-id>
/updateUser.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
\ No newline at end of file
...
...
src/main/webapp/listUsers.xhtml
View file @
9f63801
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE
composition
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
ui:composition
xmlns=
"http://www.w3.org/1999/xhtml"
<!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:p=
"http://primefaces.org/ui"
template=
"#{theme.template}"
>
xmlns:p=
"http://primefaces.org/ui"
>
<!-- <ui:composition 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:p="http://primefaces.org/ui"
template="#{theme.template}">-->
<!-- content -->
<
ui:define
name=
"content"
>
<
!--<ui:define name="content">--
>
<body>
<h2>
Liste des utilisateurs
</h2>
<p>
...
...
@@ -21,28 +26,24 @@
</p>
<h:form>
<div
id=
"search"
style=
"text-align:center;"
>
<h:panelGrid
columns=
"3"
styleClass=
"half"
>
<h:outputLabel
for=
"searchString"
value=
"Filtre"
styleClass=
"req"
/>
<h:inputText
id=
"searchString"
value=
"#{userListMgr.searchString}"
styleClass=
"req"
/>
<h:commandButton
id=
"find"
value=
"OK"
action=
"#{userListMgr.find}"
styleClass=
"lanceReq"
>
<!--<s:defaultAction/>-->
</h:commandButton>
</h:panelGrid>
<h:outputText
value=
"Pas d'lment respectant ce critre dans la base"
rendered=
"#{elementList.rowCount==0}"
/>
</div>
<!-- TODO Grer les recherches -->
<h:messages
globalOnly=
"true"
errorClass=
"errorMsg"
infoClass=
"infoMsg"
/>
<div
id=
"listElements"
>
<h:commandLink
styleClass=
"fRight acLink"
action=
"
#{userListMgr.goToCreate('user')
}"
>
<h:commandLink
styleClass=
"fRight acLink"
action=
"
add"
rendered=
"#{not empty listUsersBean.users
}"
>
<img
src=
"/images/structure/vide.gif"
class=
"icAddC"
alt=
""
title=
"Crer un nouvel utilisateur"
/>
Nouvel Utilisateur
</h:commandLink>
<p:dataTable
id=
"tableElements"
rendered=
"#{
elementList.rowCount>0
}"
var=
"user"
value=
"#{
elementList}"
rows=
"#{userListMgr.pageSize
}"
<p:dataTable
id=
"tableElements"
rendered=
"#{
not empty listUsersBean.users
}"
var=
"user"
value=
"#{
listUsersBean.users
}"
styleClass=
"results"
rowClasses=
"altRichRow,altRow"
>
<!-- TODO Grer la pagination -->
<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.users.size>0}"
var="user" value="#{listUsersBean.users}" rows="#{userListMgr.pageSize}"
styleClass="results" rowClasses="altRichRow,altRow">-->
<f:facet
name=
"header"
>
<p:dataScroller
for=
"tableElements"
stepControls=
"auto"
boundaryControls=
"auto"
fastControls=
"auto"
>
...
...
@@ -53,27 +54,29 @@
<f:facet
name=
"pages"
>
 
</f:facet>
</p:dataScroller>
</f:facet>
<p:column
rendered=
"#{s:hasRole('ADMINISTRATEUR')}"
>
<h:commandLink
id=
"delete"
onclick=
"return confirm('Voulez vous vraiment supprimer cet lment ?');"
action=
"#{userListMgr.delete}"
>
<!-- TODO Grer les droits des actions -->
<p:column>
<!-- <h:commandLink id="delete" onclick="return confirm('Voulez vous vraiment supprimer cet lment ?');" action="#{userListMgr.delete}">
<img src="/images/structure/vide.gif" class="icDel" alt="" title="Effacer" />
</h:commandLink>
</h:commandLink>
-->
</p:column>
<p:column
rendered=
"#{s:hasRole('ADMINISTRATEUR')}"
>
<
h:commandLink
action=
"#{userListMgr.goToUpdate('user', user.pk
)}"
>
<p:column>
<
!--<h:commandLink action="#{userListMgr.goToUpdate('user', user.userId
)}">
<img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" />
</h:commandLink>
</h:commandLink>
-->
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{user.username}"
>
<f:facet
name=
"header"
>
Identifiant
</f:facet>
<h:outputLink
value=
"#{user.traceable.urlRewrite}"
>
<!-- TODO Dcider de l'avenir de traceable -->
<!-- <h:outputLink value="#{user.traceable.urlRewrite}">-->
<h:outputText
value=
"#{user.username}"
/>
</h:outputLink
>
<!-- </h:outputLink>--
>
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{user.firstName} #{user.lastName}"
>
<f:facet
name=
"header"
>
Nom
</f:facet>
<
h:outputLink
value=
"#{user.traceable.urlRewrite}"
>
<
!--<h:outputLink value="#{user.traceable.urlRewrite}">--
>
<h:outputText
value=
"#{user.firstName} #{user.lastName}"
/>
<
/h:outputLink
>
<
!--</h:outputLink>--
>
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{user.email}"
>
<f:facet
name=
"header"
>
Email
</f:facet>
...
...
@@ -85,24 +88,26 @@
<h:graphicImage
value=
"/images/structure/dRouge.gif"
rendered=
"#{not user.activated}"
title=
"Utilisateur non enregistr"
/>
</p:column>
<f:facet
name=
"footer"
>
<h:commandLink
action=
"
#{userListMgr.goToCreate('user')}
"
value=
"Crer un nouvel utilisateur"
>
<h:commandLink
action=
"
add
"
value=
"Crer un nouvel utilisateur"
>
</h:commandLink>
</f:facet>
</p:dataTable>
</div>
<p>
<h:commandLink
action=
"
#{userListMgr.goToCreate('user')}
"
value=
"Crer un nouvel utilisateur"
rendered=
"#{e
lementList.rowCount==0
}"
>
<h:commandLink
action=
"
add
"
value=
"Crer un nouvel utilisateur"
rendered=
"#{e
mpty listUsersBean.users
}"
>
</h:commandLink>
</p>
</div>
</h:form>
<
/ui:define
>
</body>
<
!--</ui:define>--
>
<!-- sidebars -->
<!--
<ui:define name="sidebar">
<ui:include src="/includes/top-sidebar-admin.include"/>
</ui:define>
</ui:composition>
\ No newline at end of file
-->
</html>
<!--</ui:composition>-->
\ No newline at end of file
...
...
src/main/webapp/listUsers_short.xhtml
View file @
9f63801
...
...
@@ -11,11 +11,8 @@
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{updateUserBean.onload}"
/>
</f:metadata>
<ul>
<ui:repeat
value=
"#{
updateUser
Bean.users}"
var=
"user"
>
<ui:repeat
value=
"#{
listUsers
Bean.users}"
var=
"user"
>
<li>
#{user.username}
</li>
</ui:repeat>
</ul>
...
...
src/main/webapp/updateUser.xhtml
View file @
9f63801
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
xmlns=
"http://www.w3.org/1999/xhtml"
<!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:p=
"http://primefaces.org/ui"
>
<!--<ui:composition 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"
...
...
@@ -8,10 +13,11 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.org/ui"
template=
"#{theme.template}"
>
template="#{theme.template}">
-->
<!-- content -->
<ui:define
name=
"content"
>
<!-- <ui:define name="content">-->
<body>
<h2><h:outputText
value=
"Cration "
rendered=
"#{empty(updateUserBean.userId)}"
/>
<h:outputText
value=
"Modification "
rendered=
"#{not empty(updateUserBean.userId)}"
/>
d'un utilisateur
</h2>
...
...
@@ -65,7 +71,7 @@
</tr>
<tr>
<td><h:outputLabel
for=
"email"
>
Adresse email *
</h:outputLabel></td>
<td><h:inputText
id=
"email"
value=
"#{updateUserBean.email}"
required=
"true"
style=
"width: 175px;"
maxlength=
"100"
><
f:validator
validatorId=
"validateEmail"
/
></h:inputText></td>
<td><h:inputText
id=
"email"
value=
"#{updateUserBean.email}"
required=
"true"
style=
"width: 175px;"
maxlength=
"100"
>
<
!--<f:validator validatorId="validateEmail"/>--
>
</h:inputText></td>
<td><h:message
errorClass=
"errorMsg"
infoClass=
"infoMsg"
for=
"email"
/></td>
</tr>
<tr>
...
...
@@ -89,10 +95,12 @@
</tr>
<tr>
<td
valign=
"top"
>
<!--
<h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/>
<h:message styleClass="errorMsg" for="text"/>
-->
</td>
<td
colspan=
"2"
><
rich:editor
id=
"text"
value=
"#{updateUserBean.presentation}"
configuration=
"article-editor"
/
></td>
<td
colspan=
"2"
>
<
!--<rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/>--
>
</td>
</tr>
<ui:fragment
rendered=
"#{not empty(updateUserBean.userId)}"
>
<tr>
...
...
@@ -129,8 +137,9 @@
</tr>
<tr>
<td
colspan=
"3"
class=
"taCenter"
>
<h:commandButton
id=
"update"
value=
"Enregistrer"
action=
"#{updateUserBean.update}"
/>
 
<h:commandButton
id=
"cancel"
value=
"Annuler"
action=
"#{userMgr.cancel}"
immediate=
"true"
>
<h:commandButton
id=
"update"
value=
"Enregistrer"
action=
"#{updateUserBean.update}"
rendered=
"#{not empty(updateUserBean.userId)}"
/>
 
<h:commandButton
id=
"add"
value=
"Crer"
action=
"#{updateUserBean.add}"
rendered=
"#{empty(updateUserBean.userId)}"
/>
 
<h:commandButton
id=
"cancel"
value=
"Annuler"
action=
"cancel"
>
</h:commandButton>
</td>
</tr>
...
...
@@ -178,7 +187,7 @@
<!--</s:validateAll>-->
</h:form>
</p:panel>
<!--
<h:form rendered="#{not empty(updateUserBean.userId)}">
<h3>Dlgations</h3>
<p>
...
...
@@ -256,14 +265,16 @@
</p>
</p:panel>
</h:form>
</ui:define
>
-->
<!-- </ui:define>--
>
<!-- sidebars -->
<!--
<ui:define name="sidebar">
<ui:include src="/includes/top-sidebar-admin.include"/>
</ui:define>
</ui:composition>
</ui:define>-->
</body>
</html>
<!--</ui:composition>-->
...
...
Please
register
or
login
to post a comment