Incluido selector de tema de primefaces en pagina de bienvenida (home).
* El tema seleccionado se conserva durante la sesión. * Ya se muestran los iconos de primefaces para el tema seleccionado.
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
</context-param>
|
</context-param>
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>primefaces.THEME</param-name>
|
<param-name>primefaces.THEME</param-name>
|
||||||
<param-value>aristo</param-value>
|
<param-value>#{sessionPreferences.currentTheme}</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<!-- JSF mapping -->
|
<!-- JSF mapping -->
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<h:head>
|
<h:head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title>MyHealth Online Services</title>
|
<title>MyHealth Online Services</title>
|
||||||
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
|
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces" />
|
||||||
<h:outputStylesheet library="css" name="estilos.css" />
|
<h:outputStylesheet library="css" name="estilos.css" />
|
||||||
</h:head>
|
</h:head>
|
||||||
<h:outputScript>
|
<h:outputScript>
|
||||||
@@ -24,12 +24,14 @@
|
|||||||
<h:body>
|
<h:body>
|
||||||
<div id="layout">
|
<div id="layout">
|
||||||
<div id="top" class="top">
|
<div id="top" class="top">
|
||||||
<h1 class="Titulo">myHealth Site</h1>
|
<!-- <h1 class="Titulo">myHealth Site</h1> -->
|
||||||
|
<h:graphicImage library="images" name="logo-small.png" />
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div id="menuDiv">
|
<div id="menuDiv">
|
||||||
<h:form>
|
<h:form>
|
||||||
<p:growl id="messages" sticky="true" showDetail="true" life="3000" />
|
<p:growl id="messages" sticky="true" showDetail="true" life="3000" />
|
||||||
|
|
||||||
<p:menubar>
|
<p:menubar>
|
||||||
<p:menuitem label="Home" icon="pi pi-home" outcome="home" />
|
<p:menuitem label="Home" icon="pi pi-home" outcome="home" />
|
||||||
<p:submenu label="Administración del sistema" icon="pi pi-briefcase">
|
<p:submenu label="Administración del sistema" icon="pi pi-briefcase">
|
||||||
|
|||||||
@@ -10,12 +10,15 @@
|
|||||||
<ui:composition template="./header.xhtml">
|
<ui:composition template="./header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form>
|
<h:form>
|
||||||
|
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
|
|
||||||
<p:panel header="Pagina principal">
|
<p:panel header="Pagina principal">
|
||||||
<p:panelGrid>
|
<p:panelGrid>
|
||||||
<p:outputLabel for="basic" value="Cambio de tema" />
|
<p:outputLabel for="selectorTema" value="Cambio de tema" />
|
||||||
<p:themeSwitcher id="basic" style="width:165px">
|
<p:themeSwitcher id="selectorTema" style="width:165px" value="#{sessionPreferences.currentTheme}">
|
||||||
<f:selectItem itemLabel="Seleccione un tema" itemValue="" noSelectionOption="true" />
|
<f:selectItem itemLabel="Seleccione un tema" itemValue="" noSelectionOption="true" />
|
||||||
<f:selectItems value="#{home.themes}" var="theme" itemLabel="#{theme.displayName}" itemValue="#{theme.name}" />
|
<f:selectItems value="#{home.themes}" var="theme" itemLabel="#{theme.displayName}" itemValue="#{theme.name}" />
|
||||||
|
<p:ajax listener="#{sessionPreferences.updateCurrentTheme}" />
|
||||||
</p:themeSwitcher>
|
</p:themeSwitcher>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
<h:panelGrid columns="2">
|
<h:panelGrid columns="2">
|
||||||
@@ -31,6 +34,13 @@
|
|||||||
</h:panelGrid>
|
</h:panelGrid>
|
||||||
</h:panelGroup>
|
</h:panelGroup>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
<p:panel>
|
||||||
|
<h:panelGroup>
|
||||||
|
<h:panelGrid columns="1">
|
||||||
|
<p:commandButton value="Usar tema en este sesión" update="mesgs" action="#{sessionPreferences.updateCurrentTheme}" icon="pi pi-save" />
|
||||||
|
</h:panelGrid>
|
||||||
|
</h:panelGroup>
|
||||||
|
</p:panel>
|
||||||
</h:form>
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
|
|||||||
BIN
1.sources/MyHealth/docroot/resources/images/logo-small.png
Normal file
BIN
1.sources/MyHealth/docroot/resources/images/logo-small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -1,26 +0,0 @@
|
|||||||
package managedbean.common;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.annotation.ManagedBean;
|
|
||||||
import javax.enterprise.context.SessionScoped;
|
|
||||||
|
|
||||||
@ManagedBean
|
|
||||||
@SessionScoped
|
|
||||||
public class CurrentTheme implements Serializable {
|
|
||||||
|
|
||||||
private Theme currentTheme;
|
|
||||||
|
|
||||||
public CurrentTheme() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Theme getCurrentTheme() {
|
|
||||||
return currentTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentTheme(Theme currentTheme) {
|
|
||||||
this.currentTheme = currentTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package managedbean.common;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.annotation.ManagedBean;
|
||||||
|
import javax.enterprise.context.SessionScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
@ManagedBean
|
||||||
|
@Named("sessionPreferences")
|
||||||
|
@SessionScoped
|
||||||
|
public class SessionPreferences implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String currentTheme = "pepper-grinder";
|
||||||
|
|
||||||
|
public SessionPreferences() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrentTheme() {
|
||||||
|
return currentTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentTheme(String themeName) {
|
||||||
|
this.currentTheme = themeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCurrentTheme() {
|
||||||
|
// TODO: Se podría guardar el tema seleccionado en base de datos para el usuario
|
||||||
|
// (en caso de que esté logeado en el sistema
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null,
|
||||||
|
new FacesMessage(FacesMessage.SEVERITY_INFO, "Tema guardado", "El tema seleccionado será utilizado durante esta sesión."));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package managedbean.profile;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.ejb.EJB;
|
import javax.ejb.EJB;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
@@ -30,4 +32,11 @@ public class ProfileMBeanBase {
|
|||||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote");
|
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void manageException(Exception ex) {
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,14 +193,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
// FacesContext.getCurrentInstance().addMessage(null, msg);
|
// FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
|
||||||
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void manageException(Exception ex) {
|
|
||||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPasswordRepeat() {
|
public String getPasswordRepeat() {
|
||||||
return passwordRepeat;
|
return passwordRepeat;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,6 @@ public class LoginMBean {
|
|||||||
public String logout() {
|
public String logout() {
|
||||||
HttpSession session = SessionUtils.getSession();
|
HttpSession session = SessionUtils.getSession();
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
return "home";
|
return "home?refresh=1&faces-redirect=true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user