Clase base para todos los managedBeans con soporte para mensajes JSF,
conexión a los FacadeRemote de los EJB. Mejoras en el login de usuario. Corregido problema en registro de usuario.
This commit is contained in:
@@ -6,27 +6,31 @@
|
|||||||
<ui:composition template="./header.xhtml">
|
<ui:composition template="./header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="errorForm">
|
<h:form id="errorForm">
|
||||||
<div align="center">
|
<div class="ui-g ui-fluid">
|
||||||
<h1>Se ha producido un error</h1>
|
<div class="ui-g-2 ui-md-2" />
|
||||||
<hr />
|
<div class="ui-g-8 ui-md-8">
|
||||||
<div>Descripcion del error:</div>
|
<p:panel id="ErrorPanel" header="Se ha producido un error inesperado">
|
||||||
<div>
|
<div class="ui-g ui-fluid">
|
||||||
|
<div class="ui-g-12">La acción que estaba realizando a causado un error inesperado en el sistema. A continuación podrá ver un descripción detallada del error para que
|
||||||
|
pueda comunicarlo al equipo de soporte.</div>
|
||||||
|
|
||||||
|
<div class="ui-g-12" style="font-weight: bold;">
|
||||||
|
Descripción del error
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-g-12">
|
||||||
<h:messages fatalClass="ErrorMessage" showDetail="true" showSummary="true" globalOnly="true" />
|
<h:messages fatalClass="ErrorMessage" showDetail="true" showSummary="true" globalOnly="true" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="ui-g-12 ui-g-nopad">
|
|
||||||
<div class="ui-g-4 ui-md-5"></div>
|
|
||||||
<div class="ui-g-2 ui-md-2">
|
|
||||||
|
|
||||||
</div>
|
<div class="ui-g-5" />
|
||||||
<div class="ui-g-4 ui-md-5"></div>
|
<div class="ui-g-2">
|
||||||
</div>
|
|
||||||
<div class="ui-g-12 ui-g-nopad">
|
|
||||||
<div class="ui-g-4 ui-md-5"></div>
|
|
||||||
<div class="ui-g-2 ui-md-2">
|
|
||||||
<p:button value="Ir a la página principal" outcome="home" icon="pi pi-home" />
|
<p:button value="Ir a la página principal" outcome="home" icon="pi pi-home" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-5"></div>
|
<div class="ui-g-5" />
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-2 ui-md-2" />
|
||||||
</div>
|
</div>
|
||||||
</h:form>
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
|
|||||||
@@ -6,6 +6,43 @@
|
|||||||
|
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
|
<h:form id="frmRegisterUserResult" rendered="#{registerUser.registered}">
|
||||||
|
<div class="ui-g-3 ui-md-3" />
|
||||||
|
<div class="ui-g-6 ui-md-6">
|
||||||
|
|
||||||
|
<p:panel id="DatosPersonales" header="El registro se ha realizado correctamente">
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
|
||||||
|
<div class="ui-g-12">
|
||||||
|
Enhorabuena
|
||||||
|
<p:outputLabel value="#{registerUser.name}" />
|
||||||
|
, se ha registrado correctamente, el sistema le ha asignado un <b> <p:outputLabel value="Código de Identificación Personal (CIP)" rendered="#{registerUser.patient}" />
|
||||||
|
<p:outputLabel value="Número de Profesional" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
||||||
|
</b> , por favor recuerdelo ya que deberá utilizarlo para logearse en el sistema.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:outputLabel value="Su Código de Identificación Personal (CIP) es el siguiente:" rendered="#{registerUser.patient}" />
|
||||||
|
<p:outputLabel value="Número de Profesional es el siguiente:" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;">
|
||||||
|
<p:outputLabel value="#{registerUser.id}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-g-3"></div>
|
||||||
|
<div class="ui-g-6">
|
||||||
|
<p:button value="Ir a la página principal" outcome="home" icon="pi pi-home" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</p:panel>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3 ui-md-3" />
|
||||||
|
</h:form>
|
||||||
|
|
||||||
|
<h:form id="frmRegisterUser" rendered="#{not registerUser.registered}">
|
||||||
<h:outputScript>
|
<h:outputScript>
|
||||||
function handleRequest(xhr, status, args) {
|
function handleRequest(xhr, status, args) {
|
||||||
if(args.specs) {
|
if(args.specs) {
|
||||||
@@ -21,9 +58,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</h:outputScript>
|
</h:outputScript>
|
||||||
<h:form id="frmRegisterUser">
|
|
||||||
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
|
|
||||||
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
|
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
@@ -38,6 +73,7 @@
|
|||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
</div>
|
</div>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
<br />
|
||||||
<p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
|
<p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
@@ -105,7 +141,8 @@
|
|||||||
<p:outputLabel value="Centro:" for="selPHC" />
|
<p:outputLabel value="Centro:" for="selPHC" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-4 ui-md-4">
|
||||||
<p:selectOneMenu id="selPHC" value="#{registerUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.familyDoctor}" requiredMessage="Por favor, selecciona un centro de antención primaria">
|
<p:selectOneMenu id="selPHC" value="#{registerUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.familyDoctor}"
|
||||||
|
requiredMessage="Por favor, selecciona un centro de antención primaria">
|
||||||
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
|
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
|
||||||
<f:selectItems value="#{registerUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
|
<f:selectItems value="#{registerUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
|
||||||
<p:column>#{phc.name}</p:column>
|
<p:column>#{phc.name}</p:column>
|
||||||
@@ -122,7 +159,8 @@
|
|||||||
<p:outputLabel value="Especialidad médica:" for="selMS" />
|
<p:outputLabel value="Especialidad médica:" for="selMS" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-4 ui-md-4">
|
||||||
<p:selectOneMenu id="selMS" value="#{registerUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.specialistDoctor}" requiredMessage="Por favor, seleccione una especialidad médica" >
|
<p:selectOneMenu id="selMS" value="#{registerUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.specialistDoctor}"
|
||||||
|
requiredMessage="Por favor, seleccione una especialidad médica">
|
||||||
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
|
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
|
||||||
<f:selectItems value="#{registerUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
|
<f:selectItems value="#{registerUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
|
||||||
<p:column>#{ms.name}</p:column>
|
<p:column>#{ms.name}</p:column>
|
||||||
@@ -137,7 +175,7 @@
|
|||||||
<div class="ui-g-12 ui-g-nopad">
|
<div class="ui-g-12 ui-g-nopad">
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
<div class="ui-g-2 ui-md-2 ">
|
<div class="ui-g-2 ui-md-2 ">
|
||||||
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" />
|
<p:commandButton validateClient="true" ajax="false" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
<p:button value="Volver" outcome="home" icon="pi pi-home" />
|
<p:button value="Volver" outcome="home" icon="pi pi-home" />
|
||||||
|
|||||||
@@ -3,28 +3,30 @@
|
|||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
||||||
xmlns:p="http://primefaces.org/ui">
|
xmlns:p="http://primefaces.org/ui">
|
||||||
|
<f:metadata>
|
||||||
|
<f:viewParam name="id" value="#{registerUser.id}" />
|
||||||
|
</f:metadata>
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="frmRegisterUserResult">
|
<h:form id="frmRegisterUserResult">
|
||||||
<div class="ui-g-4 ui-md-4" />
|
<div class="ui-g-3 ui-md-3" />
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-6 ui-md-6">
|
||||||
|
|
||||||
<p:panel id="DatosPersonales" header="El registro se ha realizado correctamente">
|
<p:panel id="DatosPersonales" header="El registro se ha realizado correctamente">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
|
|
||||||
<div class="ui-g-12">
|
<div class="ui-g-12">
|
||||||
Se ha registrado correctamente, el sistema le ha asignado un <b> <p:outputLabel value="Código de Identificación Personal (CIP)" rendered="#{registerUser.patient}" /> <p:outputLabel
|
Enhorabuena <p:outputLabel value="#{registerUser.name}" />, se ha registrado correctamente, el sistema le ha asignado un <b> <p:outputLabel value="Código de Identificación Personal (CIP)" rendered="#{registerUser.patient}" /> <p:outputLabel
|
||||||
value="Número de Profesional" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
value="Número de Profesional" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
||||||
</b> , por favor recuerdelo ya que deberá utilizarlo para logearse en el sistema.
|
</b> , por favor recuerdelo ya que deberá utilizarlo para logearse en el sistema.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-12">
|
<div class="ui-g-12">
|
||||||
<p:outputLabel value="Su Código de Identificación Personal (CIP) es" rendered="#{registerUser.patient}" />
|
<p:outputLabel value="Su Código de Identificación Personal (CIP) es el siguiente:" rendered="#{registerUser.patient}" />
|
||||||
<p:outputLabel value="Número de Profesional es" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
<p:outputLabel value="Número de Profesional es el siguiente:" rendered="#{registerUser.familyDoctor or registerUser.specialistDoctor}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-12" style="font-size: larger;font-weight: bold; text-align:center;">
|
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;">
|
||||||
<p:outputLabel value="#{registerUser.id}" />
|
<p:outputLabel value="#{registerUser.id}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@
|
|||||||
|
|
||||||
</p:panel>
|
</p:panel>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4" />
|
<div class="ui-g-3 ui-md-3" />
|
||||||
</h:form>
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
|
|||||||
103
1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java
Normal file
103
1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package managedbean.common;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
import ejb.medicalTest.MedicalTestFacadeRemote;
|
||||||
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||||
|
import ejb.visit.VisitFacadeRemote;
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ManagedBeanBase {
|
||||||
|
@EJB
|
||||||
|
protected ProfileFacadeRemote remoteManagerProfile;
|
||||||
|
@EJB
|
||||||
|
protected SystemAdminFacadeRemote remoteManagerSystemAdmin;
|
||||||
|
@EJB
|
||||||
|
protected VisitFacadeRemote remoteManagerVisit;
|
||||||
|
@EJB
|
||||||
|
protected MedicalTestFacadeRemote remoteManagerMedicalTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inicializa la conexión con el EJB Remoto
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private <T> T getContext(String name, Class<T> type) {
|
||||||
|
T retObj = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Properties props = System.getProperties();
|
||||||
|
Context ctx = new InitialContext(props);
|
||||||
|
retObj = type.cast(ctx.lookup(name));
|
||||||
|
} catch (NamingException e) {
|
||||||
|
this.manageException(e);
|
||||||
|
}
|
||||||
|
return retObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ProfileFacadeRemote getRemoteManagerProfile() {
|
||||||
|
if (remoteManagerProfile == null) {
|
||||||
|
remoteManagerProfile = this.getContext("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote", ProfileFacadeRemote.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteManagerProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SystemAdminFacadeRemote getRemoteManagerSystemAdmin() {
|
||||||
|
if (remoteManagerSystemAdmin == null) {
|
||||||
|
remoteManagerSystemAdmin = this.getContext("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote", SystemAdminFacadeRemote.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteManagerSystemAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VisitFacadeRemote getRemoteManagerVisit() {
|
||||||
|
if (remoteManagerVisit == null) {
|
||||||
|
remoteManagerVisit = this.getContext("java:app/MyHealth.jar/VisitFacadeBean!ejb.systemAdmin.VisitFacadeRemote", VisitFacadeRemote.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteManagerVisit;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MedicalTestFacadeRemote getRemoteManagerMedicalTest() {
|
||||||
|
if (remoteManagerMedicalTest == null) {
|
||||||
|
remoteManagerMedicalTest = this.getContext("java:app/MyHealth.jar/MedicalTestFacadeBean!ejb.systemAdmin.MedicalTestFacadeRemote", MedicalTestFacadeRemote.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteManagerMedicalTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) {
|
||||||
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
|
|
||||||
|
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
|
||||||
|
|
||||||
|
context.getExternalContext().getFlash().setKeepMessages(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||||
|
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFacesMessage(FacesContext context, FacesMessage.Severity severity, String summary, String detail) {
|
||||||
|
context.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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,14 @@ import javax.faces.context.FacesContext;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import TO.LoggedUserTO;
|
||||||
|
|
||||||
|
|
||||||
public class SessionUtils {
|
public class SessionUtils {
|
||||||
|
public static final String SESSION_VAR_USERNAME = "userName";
|
||||||
|
public static final String SESSION_VAR_USERID = "userId";
|
||||||
|
public static final String SESSION_VAR_USERTYPE = "userType";
|
||||||
|
public static final String SESSION_VAR_USER = "loggedInUser";
|
||||||
|
|
||||||
public static HttpSession getSession() {
|
public static HttpSession getSession() {
|
||||||
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
||||||
@@ -16,6 +22,19 @@ public class SessionUtils {
|
|||||||
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CreateSession(LoggedUserTO usr) {
|
||||||
|
HttpSession ses = getSession();
|
||||||
|
ses.setAttribute(SessionUtils.SESSION_VAR_USERNAME, usr.getName());
|
||||||
|
ses.setAttribute(SessionUtils.SESSION_VAR_USERID, usr.getId());
|
||||||
|
ses.setAttribute(SessionUtils.SESSION_VAR_USERTYPE, usr.getUserType());
|
||||||
|
ses.setAttribute(SessionUtils.SESSION_VAR_USER, usr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DestroySession() {
|
||||||
|
HttpSession ses = getSession();
|
||||||
|
ses.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLogedIn() {
|
public static boolean isLogedIn() {
|
||||||
if (getUserId() == "")
|
if (getUserId() == "")
|
||||||
return false;
|
return false;
|
||||||
@@ -25,16 +44,16 @@ public class SessionUtils {
|
|||||||
|
|
||||||
public static String getUserName() {
|
public static String getUserName() {
|
||||||
HttpSession session = getSession();
|
HttpSession session = getSession();
|
||||||
if (session != null && session.getAttribute("username") != null)
|
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERNAME) != null)
|
||||||
return session.getAttribute("username").toString();
|
return session.getAttribute(SessionUtils.SESSION_VAR_USERNAME).toString();
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUserId() {
|
public static String getUserId() {
|
||||||
HttpSession session = getSession();
|
HttpSession session = getSession();
|
||||||
if (session != null && session.getAttribute("userid") != null)
|
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
|
||||||
return session.getAttribute("userid").toString();
|
return session.getAttribute(SessionUtils.SESSION_VAR_USERID).toString();
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import java.io.Serializable;
|
|||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
@@ -12,7 +14,7 @@ import javax.inject.Named;
|
|||||||
*/
|
*/
|
||||||
@Named("AddFamilyDoctorMBean")
|
@Named("AddFamilyDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -21,8 +23,7 @@ public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializab
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public AddFamilyDoctorMBean() throws Exception {
|
public AddFamilyDoctorMBean() {
|
||||||
super.initializeProfileFacadeRemote();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import javax.faces.application.FacesMessage;
|
|||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||||
* médica.
|
* médica.
|
||||||
@@ -16,7 +18,7 @@ import javax.inject.Named;
|
|||||||
*/
|
*/
|
||||||
@Named("addPatientMBean")
|
@Named("addPatientMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
public class AddPatientMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -35,8 +37,7 @@ public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public AddPatientMBean() throws Exception {
|
public AddPatientMBean() {
|
||||||
super.initializeProfileFacadeRemote();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import javax.enterprise.context.RequestScoped;
|
|||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -15,7 +16,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named( "AddSpecialistDoctorMBean")
|
@Named( "AddSpecialistDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -27,8 +28,7 @@ public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serial
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public AddSpecialistDoctorMBean() throws Exception {
|
public AddSpecialistDoctorMBean() {
|
||||||
super.initializeProfileFacadeRemote();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named( "ChangeFamilyDoctorMBean")
|
@Named( "ChangeFamilyDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ChangeFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named( "ChangePrimaryHealthCareCenterMBean")
|
@Named( "ChangePrimaryHealthCareCenterMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ChangePrimaryHealthCareCenterMBean extends ProfileMBeanBase implements Serializable {
|
public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package managedbean.profile;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.ejb.EJB;
|
|
||||||
import javax.faces.application.FacesMessage;
|
|
||||||
import javax.faces.context.FacesContext;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
|
||||||
|
|
||||||
/***
|
|
||||||
*
|
|
||||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Named("profileMBean")
|
|
||||||
public class ProfileMBeanBase {
|
|
||||||
@EJB
|
|
||||||
protected ProfileFacadeRemote remoteManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inicializa la conexión con el EJB Remoto
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
protected void initializeProfileFacadeRemote() throws Exception {
|
|
||||||
Properties props = System.getProperties();
|
|
||||||
Context ctx = new InitialContext(props);
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,8 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.faces.application.FacesMessage;
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.ExternalContext;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.view.ViewScoped;
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
@@ -24,6 +26,7 @@ import TO.PrimaryHealthCareCenterTO;
|
|||||||
import TO.SpecialistDoctorTO;
|
import TO.SpecialistDoctorTO;
|
||||||
import common.UserType;
|
import common.UserType;
|
||||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
import managedbean.common.ValidationUtils;
|
import managedbean.common.ValidationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,17 +38,19 @@ import managedbean.common.ValidationUtils;
|
|||||||
*/
|
*/
|
||||||
@Named("registerUser")
|
@Named("registerUser")
|
||||||
@ViewScoped
|
@ViewScoped
|
||||||
public class RegisterUserMBean extends ProfileMBeanBase implements Serializable {
|
public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Integer id;
|
private int id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
private String password;
|
private String password;
|
||||||
private String passwordRepeat;
|
private String passwordRepeat;
|
||||||
private String email;
|
private String email;
|
||||||
|
private boolean registered;
|
||||||
|
|
||||||
// private HashMap<String, String> userTypes;
|
// private HashMap<String, String> userTypes;
|
||||||
private List<UserType> userTypes;
|
private List<UserType> userTypes;
|
||||||
private String userType;
|
private String userType;
|
||||||
@@ -59,8 +64,8 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public RegisterUserMBean() throws Exception {
|
public RegisterUserMBean() {
|
||||||
super.initializeProfileFacadeRemote();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@@ -69,20 +74,12 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
this.userTypes.add(UserType.PATIENT);
|
this.userTypes.add(UserType.PATIENT);
|
||||||
this.userTypes.add(UserType.FAMILY_DOCTOR);
|
this.userTypes.add(UserType.FAMILY_DOCTOR);
|
||||||
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
|
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
|
||||||
|
this.registered = false;
|
||||||
|
|
||||||
this.userType = UserType.PATIENT.name();
|
this.userType = UserType.PATIENT.name();
|
||||||
|
|
||||||
Properties props = System.getProperties();
|
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
|
||||||
Context ctx;
|
this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs();
|
||||||
try {
|
|
||||||
ctx = new InitialContext(props);
|
|
||||||
SystemAdminFacadeRemote rman = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
|
|
||||||
|
|
||||||
this.medicalSpecialitiesList = rman.listAllMedicalSpecialities();
|
|
||||||
this.primaryHealthCareCentersList = rman.listAllCAPs();
|
|
||||||
} catch (NamingException e) {
|
|
||||||
this.manageException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserType> getUserTypes() {
|
public List<UserType> getUserTypes() {
|
||||||
@@ -115,19 +112,10 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
|
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
|
||||||
return medicalSpecialitiesList;
|
return medicalSpecialitiesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setMedicalSpecialtiesList(Collection<MedicalSpecialtyTO> list) {
|
|
||||||
// medicalSpecialitiesList = list;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
|
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
|
||||||
return primaryHealthCareCentersList;
|
return primaryHealthCareCentersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setPhcList(Collection<PrimaryHealthCareCenterTO> list) {
|
|
||||||
// primaryHealthCareCentersList = list;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean isPatient() {
|
public boolean isPatient() {
|
||||||
return (UserType.valueOf(this.userType) == UserType.PATIENT);
|
return (UserType.valueOf(this.userType) == UserType.PATIENT);
|
||||||
}
|
}
|
||||||
@@ -192,7 +180,7 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String addNewUser() {
|
public void addNewUser() {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
|
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
|
||||||
@@ -212,17 +200,17 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
try {
|
try {
|
||||||
switch (UserType.valueOf(this.userType)) {
|
switch (UserType.valueOf(this.userType)) {
|
||||||
case PATIENT:
|
case PATIENT:
|
||||||
PatientTO pat = this.remoteManager.registerPatient(id, nif, name, surname, password, email);
|
PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
|
||||||
this.id = pat.getId();
|
this.id = pat.getId();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case FAMILY_DOCTOR:
|
||||||
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||||
this.id = fd.getId();
|
this.id = fd.getId();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||||
this.id = sd.getId();
|
this.id = sd.getId();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -230,16 +218,13 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
throw new NotSupportedException("No se soporta el registro directo de administradores.");
|
throw new NotSupportedException("No se soporta el registro directo de administradores.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Registro realizado",
|
this.registered = true;
|
||||||
"El usuario " + name + " " + surname + " se ha registrado correctamente. Por favor, comprueba su correo electrónico para verificar su cuenta.");
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Registro realizado", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
|
||||||
|
|
||||||
return "RegisterUserResult";
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.manageException(e);
|
this.manageException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPasswordRepeat() {
|
public String getPasswordRepeat() {
|
||||||
@@ -274,4 +259,8 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
|||||||
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRegistered() {
|
||||||
|
return registered;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named( "ShowFamilyDoctorMBean")
|
@Named( "ShowFamilyDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ShowFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named("ShowPatientMBean")
|
@Named("ShowPatientMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ShowPatientMBean extends ProfileMBeanBase implements Serializable {
|
public class ShowPatientMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named( "ShowSpecialistDoctorMBean")
|
@Named( "ShowSpecialistDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ShowSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named("UpdateFamilyDoctorMBean")
|
@Named("UpdateFamilyDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class UpdateFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named("UpdatePatientMBean")
|
@Named("UpdatePatientMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class UpdatePatientMBean extends ProfileMBeanBase implements Serializable {
|
public class UpdatePatientMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
|||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
*/
|
*/
|
||||||
@Named("UpdateSpecialistDoctorMBean")
|
@Named("UpdateSpecialistDoctorMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class UpdateSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import org.primefaces.PrimeFaces;
|
|||||||
|
|
||||||
import TO.LoggedUserTO;
|
import TO.LoggedUserTO;
|
||||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
import managedbean.common.SessionUtils;
|
import managedbean.common.SessionUtils;
|
||||||
|
|
||||||
@Named("loginView")
|
@Named("loginView")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class LoginMBean {
|
public class LoginMBean extends ManagedBeanBase {
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
@@ -55,23 +56,19 @@ public class LoginMBean {
|
|||||||
|
|
||||||
if (usr != null) {
|
if (usr != null) {
|
||||||
loggedIn = true;
|
loggedIn = true;
|
||||||
HttpSession session = SessionUtils.getSession();
|
SessionUtils.CreateSession(usr);
|
||||||
session.setAttribute("username", usr.getName());
|
|
||||||
session.setAttribute("userid", "1");
|
|
||||||
session.setAttribute("userid", usr.getUserType());
|
|
||||||
session.setAttribute("loggedInUser", usr);
|
|
||||||
|
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", usr.getName());
|
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Login correcto", "Bienvenido " + usr.getName());
|
||||||
|
|
||||||
return ("home?faces-redirect=true");
|
return ("home?faces-redirect=true");
|
||||||
} else
|
} else
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_FATAL, "Error fatal", ex.getMessage());
|
this.addFacesMessage(FacesMessage.SEVERITY_FATAL, "Error fatal", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||||
|
|
||||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||||
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
||||||
@@ -81,11 +78,9 @@ public class LoginMBean {
|
|||||||
|
|
||||||
// logout event, invalidate session
|
// logout event, invalidate session
|
||||||
public String logout() {
|
public String logout() {
|
||||||
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
||||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
|
||||||
|
|
||||||
HttpSession session = SessionUtils.getSession();
|
SessionUtils.DestroySession();
|
||||||
session.invalidate();
|
|
||||||
|
|
||||||
return "home?faces-redirect=true";
|
return "home?faces-redirect=true";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user