Jean-Francois Leveque

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

......@@ -29,6 +29,20 @@
</dependencyManagement>
<dependencies>
<!-- **** PREREQUIS MIGRATION **** -->
<!-- https://mvnrepository.com/artifact/org.omnifaces/omnifaces -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
<!-- **** FRAMEWORK : JSF + CDI **** -->
......
package org.legrog.application;
import org.legrog.entities.Country;
import org.legrog.entities.CountryRepository;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.enterprise.inject.Alternative;
import javax.inject.Inject;
import java.util.List;
@Stateless
public class CountryServiceSpring implements CountryService {
@Inject
CountryRepository repository;
public void addCountry(Country country) {
repository.save(country);
}
public List<Country> getAllCountries() {
return repository.findAll();
}
}
package org.legrog.application;
import org.legrog.entities.Country;
import org.legrog.entities.DisplayNameMask;
import org.legrog.entities.UserRole;
import java.util.List;
public interface CountryService {
public interface SharedService {
void addCountry(Country country);
List<Country> getAllCountries();
}
List<DisplayNameMask> getAllDisplayNameMasks();
List<UserRole> getAvailableUserRoles();
}
\ No newline at end of file
......
package org.legrog.application;
import org.legrog.entities.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;
import java.util.Vector;
@Stateless
public class SharedServiceSpring implements SharedService {
@Inject
CountryRepository countryRepository;
@Inject
UserRoleRepository userRoleRepository;
private List<DisplayNameMask> allDisplayNameMasks;
public void addCountry(Country country) {
countryRepository.save(country);
}
public List<Country> getAllCountries() {
return countryRepository.findAll();
}
public List<DisplayNameMask> getAllDisplayNameMasks() {
if (allDisplayNameMasks == null)
{
allDisplayNameMasks = new Vector<DisplayNameMask>(DisplayNameMask.values().length);
for (DisplayNameMask mask : DisplayNameMask.values())
{
allDisplayNameMasks.add(mask);
}
}
return allDisplayNameMasks;
}
public List<UserRole> getAvailableUserRoles() {
return userRoleRepository.findAll();
}
}
package org.legrog.entities;
/* DbMaskableEntity en v2, mais je pense le nouveau nom plus clair */
public interface DisplayNameConfigurable {
String getFirstName();
String getLastName();
String getNickName();
/* ScreenName en v2, mais je pense la nouveau nom plus clair */
String getDisplayName();
}
package org.legrog.entities;
/**
* This enumeration provide options for name masking of authors and users.
* Every {link org.roliste.data.DbMaskableEntity} provide first name, last name and nickname
* capabilities, that may be "masked", thus shown in some specific way depending on chosen
* NameMask.
*/
public enum DisplayNameMask
{
PRENOMNOM("Prénom Nom")
{
public String listMask(DisplayNameConfigurable person)
{
return NOMPRENOM.getDisplayName(person);
}
public String getDisplayName(DisplayNameConfigurable person)
{
StringBuilder sb = new StringBuilder();
if (person.getFirstName() != null)
{
sb.append(person.getFirstName());
}
if (person.getLastName() != null)
{
sb.append(' ');
sb.append(person.getLastName());
}
return sb.toString();
}
},
NOMPRENOM("Nom, Prénom")
{
public String listMask(DisplayNameConfigurable person)
{
return NOMPRENOM.getDisplayName(person);
}
public String getDisplayName(DisplayNameConfigurable person)
{
StringBuilder sb = new StringBuilder();
if (person.getLastName() != null)
{
sb.append(person.getLastName());
if (person.getFirstName() != null)
{
sb.append(", ");
sb.append(person.getFirstName());
}
}
else
{
sb.append("!Pas de nom");
}
return sb.toString();
}
},
PSEUDO("Pseudo")
{
public String listMask(DisplayNameConfigurable person)
{
return PSEUDO.getDisplayName(person);
}
public String getDisplayName(DisplayNameConfigurable person)
{
StringBuilder sb = new StringBuilder();
if (person.getNickName() != null)
{
sb.append(person.getNickName());
}
else
{
sb.append("!Pas de pseudo");
}
return sb.toString();
}
},
COMPLET("Prénom 'Pseudo' Nom")
{
public String listMask(DisplayNameConfigurable person)
{
return NOMPRENOM.getDisplayName(person);
}
public String getDisplayName(DisplayNameConfigurable person)
{
StringBuffer myResult = new StringBuffer();
if (person.getFirstName() != null)
{
myResult.append(person.getFirstName());
myResult.append(' ');
}
if ( person.getNickName() != null )
{
myResult.append('\'');
myResult.append(person.getNickName());
myResult.append('\'');
myResult.append(' ');
}
if (person.getLastName() != null)
{
myResult.append(person.getLastName());
}
return myResult.toString();
}
};
private final String symbol;
private DisplayNameMask(String symbol)
{
this.symbol = symbol;
}
public String getSymbol()
{
return symbol;
}
public String toString()
{
return symbol;
}
public abstract String getDisplayName(DisplayNameConfigurable person);
public abstract String listMask(DisplayNameConfigurable person);
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ import java.util.*;
// TODO NameMask et DbMaskableEntity à traiter ensemble
@Entity
//@Table(name="utilisateur")
public class User /* extends org.roliste.data.DbTraceableEntity implements DbMaskableEntity, DbValidationEntity */ {
public class User /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ {
// @Column(name="ID_UTILISATEUR")
@Id
......@@ -40,7 +40,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
/**
* The mask used for user name.
*/
// private NameMask _mask;
private DisplayNameMask displayNameMask;
/*
@Override
public String getUrlKey()
......@@ -50,21 +50,20 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
*/
/**
* @return the user's name as desired. By default, return the complete name.
* @see org.roliste.data.db.NameMask#mask(org.roliste.data.DbMaskableEntity)
* see org.roliste.data.db.NameMask#mask(org.roliste.data.DbMaskableEntity)
*/
/*
public String getScreenName()
public String getDisplayName()
{
if (_mask != null)
return _mask.mask(this);
if (displayNameMask != null)
return displayNameMask.getDisplayName(this);
else
return NameMask.COMPLET.mask(this);
return DisplayNameMask.COMPLET.getDisplayName(this);
}
*/
/**
* Returns the user's name mask.
* @return the mask.
* @see #setNameMask(NameMask)
* see #setNameMask(NameMask)
* hibernate.property
* column="MASQUE_NOM_UTILISATEUR"
* access="property"
......@@ -72,21 +71,18 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
* @hibernate.type
* name="org.roliste.data.util.NameMaskUserType"
*/
/*
public NameMask getNameMask() {
return _mask;
public DisplayNameMask getDisplayNameMask() {
return displayNameMask;
}
*/
/**
* Initializes the user's name mask.
* @param mask the new {@link org.roliste.data.db.NameMask}.
* @see #getNameMask()
* @param mask the new {link org.roliste.data.db.NameMask}.
* see #getNameMask()
*/
/*
public void setNameMask(NameMask mask) {
_mask = mask;
public void setDisplayNameMask(DisplayNameMask mask) {
mask = mask;
}
*/
// TODO Faire ailleurs les contrôles de chaîne vide sur : username, password, firstname, lastname, nickname, email, text
......@@ -111,7 +107,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
private String lastName;
/**
* The user screen name.
* The user nick name.
*/
private String nickname;
......@@ -123,7 +119,8 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
/**
* The {@link org.roliste.data.db.UserRole}s for this user.
*/
// private List<UserRole> _roles;
@ManyToMany
private List<UserRole> roles;
/**
* Retrieves the list of {@link UserRole}s for this user.
......@@ -134,7 +131,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
* @see #setRoles(List)
* @see #addToRole(UserRole)
* @see #removeFromRole(UserRole)
* @hibernate.many-to-many
* hibernate.many-to-many
* column="ROLE_FK"
* class="org.roliste.data.db.UserRole"
* foreign-key="FK_UTILISATEURROLE_ROLEUTILISATEUR"
......@@ -148,28 +145,28 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
* table="role_utilisateur"
* lazy="true"
*/
/*
public List<UserRole> getRoles() {
return _roles;
return roles;
}
*/
/**
* Lists the list of {@link UserRole}s for this user.
* @param roles the new {@link List} of {@link UserRole}s. Shall not be <code>null</code>.
* @throws NullPointerException if roles is <code>null</code>.
* @see #getRoles()
* @see #addToRole(UserRole)
* @see #removeFromRole(UserRole)
* see #addToRole(UserRole)
* see #removeFromRole(UserRole)
*/
/*
public void setRoles(List<UserRole> roles) {
if (roles == null)
{
throw new NullPointerException("Impossible d'affecter un ensemble nul aux r�les d'un utilisateur");
}
_roles = roles;
this.roles = roles;
}
*/
/**
* Add the user to a given {@link UserRole}s.
* @param role the new {@link UserRole}. Ignored if <code>null</code>.
......@@ -232,7 +229,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
/**
* Presentation text.
*/
private String text;
private String presentation;
/**
* The {@link org.roliste.data.db.BookDetails}s in this user's collection.
......@@ -736,16 +733,16 @@ public class User /* extends org.roliste.data.DbTraceableEntity implements DbMas
* length="2147483647"
*/
public String getPresentation() {
return text;
return presentation;
}
/**
* Initializes the HTML text presentation.
* @param text the new {@link String} HTML text.
* @param presentation the new {@link String} HTML text.
* @see #getPresentation()
*/
public void setPresentation(String text) {
this.text = text;
public void setPresentation(String presentation) {
this.presentation = presentation;
}
/**
......
package org.legrog.entities;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
/**
* The database representation of a user role or group.
* A given {@link User} may be part of one or more {@link UserRole}.
* <br/>
* Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly.
* You shall always use the getter/setter methods.
* alias UserRole
*
*/
@Entity
// TODO évaluer extend v2
public class UserRole /* extends org.roliste.data.DbEntity */
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userRoleId;
/**
* The role identifier.
*/
private String rolename;
/**
* The {@link User}s for this user role.
*/
@ManyToMany
private Set<User> users;
/**
* Builds a new and empty user role definition.
* All attributes are set to their default value.
* <br/>
* Needed by Hibernate for Java reflection.
*/
public UserRole() {
super();
rolename = null;
visible = true;
// no need to synchronize this
users = new HashSet<User>();
}
public int getUserRoleId() {
return userRoleId;
}
public void setUserRoleId(int userRoleId) {
this.userRoleId = userRoleId;
}
/**
* Returns the role identifier.
* @return the {@link String} identifier.
* @see #setRolename(String)
* hibernate.property
* column="NOM_ROLE"
* not-null="true"
* unique="true"
* access="property"
* length="50"
*/
public String getRolename() {
return rolename;
}
/**
* Initializes the role identifier.
* @param name the new {@link String} identifier.
* @see #getRolename()
*/
public void setRolename(String name) {
rolename = name;
}
/**
* The role validation status.
* A role may be temporarily deactivated.
*/
private boolean visible;
/**
* Indicates if the role is visible.
* If not, users should not be able to access the privileges
* they inherit from being part of this role.
* @return the visible flag.
* @see #setVisible(boolean)
* hibernate.property
* column="IND_VISIBLE"
* access="property"
*/
public boolean isVisible() {
return visible;
}
/**
* Initializes the user visible flag.
* @param visible the new flag value.
* @see #isVisible
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
/**
* Retrieves the list of {@link User}s for this user role.
* SHALL be used as a read-only attribute. In particular, avoid
* using {@link Set#add(Object)} or {@link Set#remove(Object)} on
* the returned value without caution.
* @return a {@link Set} of {@link User}. May be <code>null</code>.
* @see #setUsers(Set)
* hibernate.many-to-many
* column="UTILISATEUR_FK"
* class="org.roliste.data.db.User"
* foreign-key="FK_UTILISATEURROLE_UTILISATEUR"
* hibernate.key
* column="ROLE_FK"
* not-null="true"
* foreign-key="FK_UTILISATEURROLE_ROLEUTILISATEUR"
* hibernate.set
* access="property"
* table="role_utilisateur"
* lazy="true"
* inverse="true"
*/
public Set<User> getUsers() {
return users;
}
/**
* Sets the list of {@link User}s for this user role.
* @param users the new {@link Set} of {@link User}s. May be
* <code>null</code> (we don't handle the relation from this side).
* @see #getUsers()
*/
protected void setUsers(Set<User> users) {
this.users = users;
}
/**
* Returns a string representation of this user role definition.
* @return a string representing this user role definition.
* hidden
*/
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ID_ROLE=");
sb.append(getUserRoleId());
sb.append(" NOM_ROLE=");
sb.append(rolename);
sb.append(" IND_VISIBLE=");
sb.append(visible);
return sb.toString();
}
}
\ No newline at end of file
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRoleRepository extends JpaRepository<UserRole, Integer> {
}
\ No newline at end of file
package org.legrog.presentation;
import org.legrog.application.CountryService;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;
@Named
@RequestScoped
public class CountryBean {
public class AddCountryBean {
@Inject
private CountryService service;
private List<Country> countries;
private SharedService sharedService;
private String countryName;
public List<Country> getCountries() {
return countries;
}
public void setCountries(List<Country> countries) {
this.countries = countries;
}
public String getCountryName() {
return countryName;
}
......@@ -38,11 +27,8 @@ public class CountryBean {
{
Country country = new Country();
country.setCountryName(countryName);
service.addCountry(country);
sharedService.addCountry(country);
return "success";
}
public void onload() {
countries = service.getAllCountries();
}
}
......
package org.legrog.presentation;
import org.legrog.application.SharedService;
import org.legrog.application.UserService;
import org.legrog.entities.DisplayNameMask;
import org.legrog.entities.User;
import org.legrog.entities.UserRole;
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 AddUserBean {
@Inject
private UserService userService;
@Inject
private SharedService sharedService;
private int userId;
private String username;
private String firstName;
private String lastName;
private String nickName;
private DisplayNameMask displayNameMask;
private List<DisplayNameMask> allDisplayNameMasks;
private List<UserRole> availableUserRoles;
private String email;
private boolean anonymous;
private String password;
private List<UserRole> roles;
private String presentation;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String add()
{
User user = new User();
user.setUsername(username);
userService.addUser(user);
return "success";
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public DisplayNameMask getDisplayNameMask() {
return displayNameMask;
}
public void setDisplayNameMask(DisplayNameMask displayNameMask) {
this.displayNameMask = displayNameMask;
}
public List<DisplayNameMask> getAllDisplayNameMasks() {
return allDisplayNameMasks;
}
public void setAllDisplayNameMasks(List<DisplayNameMask> allDisplayNameMasks) {
this.allDisplayNameMasks = allDisplayNameMasks;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean isAnonymous() {
return anonymous;
}
public void setAnonymous(boolean anonymous) {
this.anonymous = anonymous;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<UserRole> getRoles() {
return roles;
}
public void setRoles(List<UserRole> roles) {
this.roles = roles;
}
@PostConstruct
public void init() {
allDisplayNameMasks = sharedService.getAllDisplayNameMasks();
availableUserRoles = sharedService.getAvailableUserRoles();
}
public List<UserRole> getAvailableUserRoles() {
return availableUserRoles;
}
public void setAvailableUserRoles(List<UserRole> availableUserRoles) {
this.availableUserRoles = availableUserRoles;
}
public String getPresentation() {
return presentation;
}
public void setPresentation(String presentation) {
this.presentation = presentation;
}
}
package org.legrog.presentation;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
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 ListCountriesBean {
@Inject
private SharedService sharedService;
private List<Country> countries;
public List<Country> getCountries() {
return countries;
}
public void setCountries(List<Country> countries) {
this.countries = countries;
}
@PostConstruct
public void init() {
countries = sharedService.getAllCountries();
}
}
......@@ -3,18 +3,13 @@ package org.legrog.presentation;
import org.legrog.application.UserService;
import org.legrog.entities.User;
import javax.enterprise.context.RequestScoped;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;
@Named
@RequestScoped
public class UserBean {
public class ListUsersBean {
@Inject
private UserService service;
private String username;
private UserService userService;
private List<User> users;
......@@ -26,24 +21,9 @@ public class UserBean {
this.users = users;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String add()
{
User user = new User();
user.setUsername(username);
service.addUser(user);
return "success";
}
public void onload() {
users = service.getAllUsers();
@PostConstruct
public void init() {
users = userService.getAllUsers();
}
}
......
......@@ -37,7 +37,7 @@
</navigation-case>
<navigation-case>
<from-outcome>listUsers</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
<to-view-id>/listUsers_short.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
......@@ -53,7 +53,7 @@
<from-view-id>/addUser.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
<to-view-id>/listUsers_short.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
......
......@@ -13,9 +13,9 @@
<h:panelGrid columns="2">
<h:outputText value='Nom du pays'/>
<h:inputText value='#{countryBean.countryName}'/>
<h:inputText value='#{addCountryBean.countryName}'/>
<h:outputText value='Add'/>
<h:commandButton action="#{countryBean.add}" value="Add"/>
<h:commandButton action="#{addCountryBean.add}" value="Add"/>
</h:panelGrid>
</h:form>
</body>
......
......@@ -13,9 +13,9 @@
<h:panelGrid columns="2">
<h:outputText value="Username de l'utilisateur"/>
<h:inputText value='#{userBean.username}'/>
<h:inputText value='#{addUserBean.username}'/>
<h:outputText value='Add'/>
<h:commandButton action="#{userBean.add}" value="Add"/>
<h:commandButton action="#{addUserBean.add}" value="Add"/>
</h:panelGrid>
</h:form>
</body>
......
......@@ -11,11 +11,8 @@
<h:outputText value="Menu principal"/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event type="preRenderView" listener="#{countryBean.onload}" />
</f:metadata>
<ul>
<ui:repeat value="#{countryBean.countries}" var="country">
<ui:repeat value="#{listCountriesBean.countries}" var="country">
<li>#{country.countryName}</li>
</ui:repeat>
</ul>
......
<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:form>
<h:commandLink action="home">
<h:outputText value="Menu principal"/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event type="preRenderView" listener="#{userBean.onload}" />
</f:metadata>
<ul>
<ui:repeat value="#{userBean.users}" var="user">
<li>#{user.username}</li>
</ui:repeat>
</ul>
</f:view>
</html>
<?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"
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">
<h2>Liste des utilisateurs</h2>
<p>
Liste des utilisateurs enregistrs sur le site. Un utilisateur peut tre "visible" ou non. Dans
le cas o il n'est pas visible, il lui est impossible de s'identifier sur le site. Au moment de
son enregistrement, par dfaut, il n'est pas visible : un systme de confirmation par courriel permet
de valider que l'adresse est correcte, et seulement ce moment l de le rendre visible. La cration
d'un utilisateur directement partir de la passerelle n'utilise pas ce systme de confirmation.
</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>
<h:messages globalOnly="true" errorClass="errorMsg" infoClass="infoMsg"/>
<div id="listElements">
<h:commandLink styleClass="fRight acLink" action="#{userListMgr.goToCreate('user')}" >
<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}"
styleClass="results" rowClasses="altRichRow,altRow">
<f:facet name="header">
<p:dataScroller for="tableElements"
stepControls="auto" boundaryControls="auto" fastControls="auto">
<f:facet name="first">Premiers</f:facet>
<f:facet name="last">Derniers</f:facet>
<f:facet name="fastforward">Suivants</f:facet>
<f:facet name="fastrewind">Prcdents</f:facet>
<f:facet name="pages" >&#160;</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}">
<img src="/images/structure/vide.gif" class="icDel" alt="" title="Effacer" />
</h:commandLink>
</p:column>
<p:column rendered="#{s:hasRole('ADMINISTRATEUR')}">
<h:commandLink action="#{userListMgr.goToUpdate('user', user.pk)}">
<img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" />
</h:commandLink>
</p:column>
<p:column styleClass="third" sortBy="#{user.username}">
<f:facet name="header">Identifiant</f:facet>
<h:outputLink value="#{user.traceable.urlRewrite}">
<h:outputText value="#{user.username}" />
</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:outputText value="#{user.firstName} #{user.lastName}" />
</h:outputLink>
</p:column>
<p:column styleClass="third" sortBy="#{user.email}">
<f:facet name="header">Email</f:facet>
<h:outputText value="#{user.email}" />
</p:column>
<p:column>
<h:graphicImage value="/images/structure/dVert.gif" rendered="#{user.visible and user.activated}" title="Utilisateur activ" />
<h:graphicImage value="/images/structure/dOrange.gif" rendered="#{(not user.visible) and user.activated}" title="Utilisateur dsactiv" />
<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>
</f:facet>
</p:dataTable>
<p>
<h:commandLink action="#{userListMgr.goToCreate('user')}" value="Crer un nouvel utilisateur"
rendered="#{elementList.rowCount==0}">
</h:commandLink>
</p>
</div>
</h:form>
</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
......
<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:form>
<h:commandLink action="home">
<h:outputText value="Menu principal"/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event type="preRenderView" listener="#{addUserBean.onload}" />
</f:metadata>
<ul>
<ui:repeat value="#{addUserBean.users}" var="user">
<li>#{user.username}</li>
</ui:repeat>
</ul>
</f:view>
</html>
<?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"
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:s="http://jboss.com/products/seam/taglib"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.org/ui"
template="#{theme.template}">
<!-- content -->
<ui:define name="content">
<h2><h:outputText value="Cration " rendered="#{empty(addUserBean.userId)}"/>
<h:outputText value="Modification " rendered="#{not empty(addUserBean.userId)}"/>d'un utilisateur</h2>
<p>
Les rles sont hirarchiss, et la hirarchie est automatiquement applique lorsque vous
sauvegardez un utilisateur. Par exemple, un administrateur est forcment visiteur, recrue
et contributeur. Si vous souhaitez laisser la possibilit un utilisateur de s'identifier
sur le site, mais sans pouvoir raliser aucune action, il suffit de le dsinscrire de tous
les rles y compris celui de visiteur. Mettre un utilisateur la "retraite" le dsinscrit
automatiquement de tous les groupes, l'exception du groupe des simples visiteurs.
<br/>
<strong>Attention :</strong> chaque section est sauvegarde et utilisable sparemment.
</p>
<p>
<h:messages globalOnly="true" errorClass="errorMsg" infoClass="infoMsg"/>
</p>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Informations"
switchType="ajax" opened="true">
<h:form>
<!-- <s:validateAll>-->
<table class="noMargin">
<tr>
<td><h:outputLabel for="username">Identifiant *</h:outputLabel></td>
<td><h:inputText id="username" value="#{addUserBean.username}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="username"/></td>
</tr>
<tr>
<td><h:outputLabel for="firstname">Prnom *</h:outputLabel></td>
<td><h:inputText id="firstname" value="#{addUserBean.firstName}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="firstname"/></td>
</tr>
<tr>
<td><h:outputLabel for="lastname">Nom *</h:outputLabel></td>
<td><h:inputText id="lastname" value="#{addUserBean.lastName}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="lastname"/></td>
</tr>
<tr>
<td><h:outputLabel for="nickname">Pseudonyme</h:outputLabel></td>
<td><h:inputText id="nickname" value="#{addUserBean.nickName}" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="nickname"/></td>
</tr>
<tr>
<td><h:outputLabel for="mask">Affichage public du nom *</h:outputLabel></td>
<td>
<h:selectOneMenu id="mask" value="#{addUserBean.displayNameMask}" converter="omnifaces.SelectItemsConverter" required="true" style="width: 175px;">
<f:selectItems value="#{addUserBean.allDisplayNameMasks}"/>
</h:selectOneMenu>
</td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="mask"/></td>
</tr>
<tr>
<td><h:outputLabel for="email">Adresse email *</h:outputLabel></td>
<td><h:inputText id="email" value="#{addUserBean.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>
<td><h:outputLabel for="anonymous">Profil Anonyme ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="anonymous" value="#{addUserBean.anonymous}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="anonymous"/></td>
</tr>
<tr>
<td><h:outputLabel for="password">Mot de passe *</h:outputLabel></td>
<td><h:inputSecret id="password" redisplay="true" value="#{addUserBean.password}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="password"/></td>
</tr>
<tr>
<td><h:outputLabel for="roles">Rles</h:outputLabel></td>
<td>
<h:selectManyCheckbox id="roles" value="#{addUserBean.roles}" converter="omnifaces.SelectItemsConverter" layout="pageDirection" >
<f:selectItems value="#{addUserBean.availableUserRoles}" var="role" label="#{role.rolename}" />
</h:selectManyCheckbox>
</td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="roles"/></td>
</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="#{addUserBean.presentation}" configuration="article-editor"/></td>
</tr>
<ui:fragment rendered="#{not empty(addUserBean.userId)}">
<tr>
<td colspan="3" class="taCenter">
<h:dataTable style="width:75%" headerClass="colDroite"
var="userProperty" value="#{common.availableUserProperties}">
<h:column>
<f:facet name="header"><h:outputLabel>Proprits</h:outputLabel></f:facet>
<h:outputText value="#{userProperty.tag}"/>
</h:column>
<h:column>
<h:inputText id="prop_#{userProperty.name}" value="#{userMgr.userAttributes[userProperty.name].value}" style="width: 175px;">
<f:validateLength maximum="200"/>
</h:inputText>
</h:column>
</h:dataTable>
</td>
</tr>
</ui:fragment>
<tr>
<td><h:outputLabel for="criticProvider">Archives de critiques ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="criticProvider" value="#{addUserBean.criticProvider}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="criticProvider"/></td>
</tr>
<tr>
<td><h:outputLabel for="visible">Visible ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="visible" value="#{addUserBean.visible}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="visible"/></td>
</tr>
<tr>
<td><h:outputLabel for="activated">Activ ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="activated" value="#{addUserBean.activated}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="activated"/></td>
</tr>
<tr>
<td colspan="3" class="taCenter">
<h:commandButton id="update" value="Enregistrer" action="#{userMgr.save}"/>&#160;
<h:commandButton id="cancel" value="Annuler" action="#{userMgr.cancel}" immediate="true">
</h:commandButton>
</td>
</tr>
</table>
<!--</s:validateAll>-->
</h:form>
</p:panel>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Import d'anciennes donnes"
switchType="ajax" opened="true" rendered="#{not empty(addUserBean.userId)}">
<h:form>
<!-- <s:validateAll>-->
<p>
La prsente section est destine raffecter des critiques, des commentaires ou des
articles posts dans le Grog v1 par cet utilisateur. N'effectuez cette opration qu'en
connaissance de cause, et aprs avoir ventuellement vrifi l'identit de la personne
(par exemple, via le systme de demande de raffectation prsent sur la page des profils
utilisateurs). Entrez l'adresse email utilise dans les anciennes critiques (ou les anciens
articles) ou son pseudo, et cliquez sur le bouton 'Affecter des critiques'. Le lien se fera automatiquement,
aussi bien pour les critiques sur les jeux pros que pour les commentaires sur les jdra, ou
pour les articles, s'il y a lieu.
</p>
<p>
<strong>Attention !</strong> Les donnes, une fois affectes, ne pourront plus tre raffectes
par ce biais. D'autre part, entrez la vritable adresse email, incluant le caractre '@',
mme si l'utilisateur a post des critiques sous une adresse masque (ne lancez pas cette
commande avec titi_AT_toto.fr mais avec titi@toto.fr, par exemple).
<br/>
Si vous souhaitez faire l'affectation pour un pseudo d'auteur, sans email, rentrez simplement le nom
de l'auteur.
</p>
<table class="noMargin">
<tr>
<td><h:outputLabel for="import_email">Email / Pseudo</h:outputLabel></td>
<td><h:inputText id="import_email" value="#{userMgr.importEmail}" required="true" style="width: 175px;"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="import_email"/></td>
</tr>
<tr>
<td colspan="3" class="taCenter">
<h:commandButton id="import" value="Affecter des critiques" action="#{userMgr.importCritics}"/>
</td>
</tr>
</table>
<!--</s:validateAll>-->
</h:form>
</p:panel>
<h:form rendered="#{not empty(addUserBean.userId)}">
<h3>Dlgations</h3>
<p>
Les sections suivantes rpertorient les diffrents lments pour lesquels l'utilisateur
s'est vu dlguer la possibilit de modifier certaines donnes. Attention, ceci ne correspond
par la possibilit, pour un contributeur, de mettre jour les donnes de la base.
Il s'agit ici de donner la main un visiteur extrieur sur un ensemble limit d'objets.
Par exemple, permettre un diteur d'accder son planning ou sa fiche d'diteur,
ou encore permettre un auteur de jeu indpendant de modifier la fiche de son jeu.
Toute modification par un dlgu peut donner lieu un message d'avertissement la
passerelle, ou ce que l'lment repasse en validation...
</p>
<p>
<strong>Avertissement :</strong> pour les diteurs et les partenaires, veillez bien toujours
vrifier l'identit des personnes dlgues, et vrifier ventuellement par courriel
ou tlphone que la demande de dlgation a bien t faite par l'diteur. L'affichage
des sections "dlgations" ci-dessous peut tre un peu lent, en raison du nombre d'objets
dans la base, soyez patient aprs avoir cliqu...
</p>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Dlgation - Jeux amateurs"
switchType="ajax" opened="false" eventsQueue="myEvents" requestDelay="400">
<rich:pickList styleClass="noMargin"
showButtonsLabel="false" listsHeight="200px" sourceListWidth="200px" targetListWidth="200px"
value="#{userMgr.delegatedIndieGames}" >
<s:selectItems value="#{common.indieGames}" var="indieGame" label="#{indieGame.title}"/>
<s:convertEntity />
</rich:pickList>
<p>
<h:commandButton value="Enregistrer les dlgations" action="#{userMgr.saveDeleg}">
</h:commandButton>
</p>
</p:panel>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Dlgation - diteurs"
switchType="ajax" opened="false" eventsQueue="myEvents" requestDelay="400">
<rich:pickList styleClass="noMargin"
showButtonsLabel="false" listsHeight="200px" sourceListWidth="200px" targetListWidth="200px"
value="#{userMgr.delegatedPublishers}" >
<s:selectItems value="#{common.availablePublishers}" var="pub" label="#{pub.pubName}"/>
<s:convertEntity />
</rich:pickList>
<p>
<h:commandButton value="Enregistrer les dlgations" action="#{userMgr.saveDeleg}">
</h:commandButton>
</p>
</p:panel>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Dlgation - Partenaires"
switchType="ajax" opened="false" eventsQueue="myEvents" requestDelay="400">
<rich:pickList styleClass="noMargin"
showButtonsLabel="false" listsHeight="200px" sourceListWidth="200px" targetListWidth="200px"
value="#{userMgr.delegatedPartners}" >
<s:selectItems value="#{common.partnerList}" var="partner" label="#{partner.name}"/>
<s:convertEntity />
</rich:pickList>
<p>
<h:commandButton value="Enregistrer les dlgations" action="#{userMgr.saveDeleg}">
</h:commandButton>
</p>
</p:panel>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Dlgation - Biographies"
switchType="ajax" opened="false" eventsQueue="myEvents" requestDelay="400">
<rich:pickList styleClass="noMargin"
showButtonsLabel="false" listsHeight="200px" sourceListWidth="200px" targetListWidth="200px"
value="#{userMgr.delegatedAuthors}" >
<s:selectItems value="#{common.availableAuthors}" var="author" label="#{author.listName}"/>
<s:convertEntity />
</rich:pickList>
<p>
<h:commandButton value="Enregistrer les dlgations" action="#{userMgr.saveDeleg}">
</h:commandButton>
</p>
</p:panel>
</h:form>
</ui:define>
<!-- sidebars -->
<ui:define name="sidebar">
<ui:include src="/includes/top-sidebar-admin.include"/>
</ui:define>
</ui:composition>