* Implementado esqueleto de menu principal.
* Filtro AuthorizationFilter para gestionar inicio de sesión. * Interfaz para página de login básica. * Todos los managed beans movidos a paquete managedbean * Configuración básica de faces-config con navegación de paginas outcome. * Actualizado web.xml * Utilización de librería primefaces para interfaz de usuario. * Aplicado tema bootstrap para primefaces. * Los iconos (glyph-icons) de primefaces no se cargan en la interfaz (Pendiente de investigar). * Actualización de projects archives para inclusión de clases nuevas en JAR/WAR/EAR de forma correcta.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
|
||||
package managedbean.common;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@WebFilter(filterName = "AuthFilter", urlPatterns = { "*.xhtml" })
|
||||
public class AuthorizationFilter implements Filter {
|
||||
|
||||
public AuthorizationFilter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
try {
|
||||
|
||||
HttpServletRequest reqt = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
HttpSession ses = reqt.getSession(false);
|
||||
|
||||
String reqURI = reqt.getRequestURI();
|
||||
if (reqURI.indexOf("/login.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|
||||
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource"))
|
||||
chain.doFilter(request, response);
|
||||
else
|
||||
resp.sendRedirect(reqt.getContextPath() + "/login.xhtml");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
115
1.sources/MyHealth/src/managedbean/common/MenuMBean.java
Normal file
115
1.sources/MyHealth/src/managedbean/common/MenuMBean.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package managedbean.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.model.menu.DefaultMenuItem;
|
||||
import org.primefaces.model.menu.DefaultMenuModel;
|
||||
import org.primefaces.model.menu.DefaultSubMenu;
|
||||
import org.primefaces.model.menu.MenuModel;
|
||||
|
||||
@Named("menuView")
|
||||
@RequestScoped
|
||||
public class MenuMBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private MenuModel model;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
model = new DefaultMenuModel();
|
||||
|
||||
// First submenu
|
||||
DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic submenu");
|
||||
DefaultMenuItem item = new DefaultMenuItem("External", "", "www.google.com");
|
||||
// item.setUrl("www.google.com");
|
||||
firstSubmenu.getElements().add(item);
|
||||
|
||||
model.getElements().add(firstSubmenu);
|
||||
|
||||
// Second submenu
|
||||
DefaultSubMenu secondSubmenu = new DefaultSubMenu("Dynamic Actions");
|
||||
|
||||
item = new DefaultMenuItem("Save", "pi pi-save");
|
||||
item.setCommand("#{menuView.save}");
|
||||
item.setUpdate("messages");
|
||||
secondSubmenu.getElements().add(item);
|
||||
|
||||
item = new DefaultMenuItem("Delete", "pi pi-times");
|
||||
item.setCommand("#{menuView.delete}");
|
||||
item.setAjax(false);
|
||||
secondSubmenu.getElements().add(item);
|
||||
|
||||
item = new DefaultMenuItem("Redirect", "pi pi-search");
|
||||
item.setCommand("#{menuView.redirect}");
|
||||
secondSubmenu.getElements().add(item);
|
||||
|
||||
model.getElements().add(secondSubmenu);
|
||||
}
|
||||
|
||||
public MenuModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
addMessage("Success", "Data saved");
|
||||
}
|
||||
|
||||
public void update() {
|
||||
addMessage("Success", "Data updated");
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
addMessage("Success", "Data deleted");
|
||||
}
|
||||
|
||||
public String goManageSpecialties() {
|
||||
|
||||
return "ManageSpecialties";
|
||||
}
|
||||
|
||||
public String goVisit() {
|
||||
return "VisitView";
|
||||
}
|
||||
|
||||
public String goMedicalTests() {
|
||||
return "MedicalTests";
|
||||
}
|
||||
|
||||
public String goListSpecialistDoctors() {
|
||||
return "header";
|
||||
}
|
||||
|
||||
public String goListSpecialistDoctorsBySpecialty() {
|
||||
return "header";
|
||||
}
|
||||
|
||||
public String goListaFamilyDoctors() {
|
||||
return "header";
|
||||
}
|
||||
|
||||
public String goChangeDoctor() {
|
||||
return "header";
|
||||
}
|
||||
|
||||
public String goChangeCAP() {
|
||||
return "header";
|
||||
}
|
||||
|
||||
public String goAddPatient() {
|
||||
return "profile/AddPaciente";
|
||||
}
|
||||
|
||||
public void addMessage(String summary, String detail) {
|
||||
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, detail);
|
||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||
}
|
||||
}
|
||||
41
1.sources/MyHealth/src/managedbean/common/SessionUtils.java
Normal file
41
1.sources/MyHealth/src/managedbean/common/SessionUtils.java
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
package managedbean.common;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
||||
public class SessionUtils {
|
||||
|
||||
public static HttpSession getSession() {
|
||||
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
||||
}
|
||||
|
||||
public static boolean isLogedIn() {
|
||||
if (getUserId() == "")
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getUserName() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute("username") != null)
|
||||
return session.getAttribute("username").toString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getUserId() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute("userid") != null)
|
||||
return session.getAttribute("userid").toString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
41
1.sources/MyHealth/src/managedbean/common/homeMBean.java
Normal file
41
1.sources/MyHealth/src/managedbean/common/homeMBean.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package managedbean.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("home")
|
||||
@RequestScoped
|
||||
public class homeMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean isLogedIn;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
isLogedIn = SessionUtils.isLogedIn();
|
||||
}
|
||||
|
||||
public boolean isLogedIn() {
|
||||
return this.isLogedIn;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
if (this.isLogedIn == false)
|
||||
return "Invitado";
|
||||
else
|
||||
return SessionUtils.getUserName();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return SessionUtils.getUserId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -18,8 +18,8 @@ import ejb.medicalTest.MedicalTestFacadeRemote;
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "MedicalTestMBean")
|
||||
@SessionScoped
|
||||
@Named("MedicalTestMBean")
|
||||
@RequestScoped
|
||||
public class MedicalTestMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "AddFamilyDoctorMBean")
|
||||
@SessionScoped
|
||||
public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
@Named("AddFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -31,5 +25,4 @@ public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializab
|
||||
super.initializeProfileFacadeRemote();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ package managedbean.profile;
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -18,8 +17,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "AddPatientMBean")
|
||||
@SessionScoped
|
||||
@Named( "AddPatientMBean")
|
||||
@RequestScoped
|
||||
public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
|
||||
@@ -16,8 +13,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "AddSpecialistDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named( "AddSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ChangeFamilyDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named( "ChangeFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ChangeFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ChangePrimaryHealthCareCenterMBean")
|
||||
@SessionScoped
|
||||
@Named( "ChangePrimaryHealthCareCenterMBean")
|
||||
@RequestScoped
|
||||
public class ChangePrimaryHealthCareCenterMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -3,11 +3,13 @@ package managedbean.profile;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
|
||||
@Named("profileMBean")
|
||||
public class ProfileMBeanBase {
|
||||
@EJB
|
||||
protected ProfileFacadeRemote remoteManager;
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ShowFamilyDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named( "ShowFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ShowPatientMBean")
|
||||
@SessionScoped
|
||||
@Named("ShowPatientMBean")
|
||||
@RequestScoped
|
||||
public class ShowPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -42,8 +42,7 @@ public class ShowPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ShowSpecialistDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named( "ShowSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "UpdateFamilyDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named("UpdateFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -42,8 +42,7 @@ public class UpdateFamilyDoctorMBean extends ProfileMBeanBase implements Seriali
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "UpdatePatientMBean")
|
||||
@SessionScoped
|
||||
@Named("UpdatePatientMBean")
|
||||
@RequestScoped
|
||||
public class UpdatePatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -42,8 +42,7 @@ public class UpdatePatientMBean extends ProfileMBeanBase implements Serializable
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -16,8 +16,8 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "UpdateSpecialistDoctorMBean")
|
||||
@SessionScoped
|
||||
@Named("UpdateSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -42,8 +42,7 @@ public class UpdateSpecialistDoctorMBean extends ProfileMBeanBase implements Ser
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,63 +1,56 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import common.SessionUtils;
|
||||
import org.primefaces.PrimeFaces;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ManagedBean(name = "login")
|
||||
@SessionScoped
|
||||
public class LoginMBean implements Serializable {
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
private static final long serialVersionUID = 1094801825228386363L;
|
||||
@Named("loginView")
|
||||
@RequestScoped
|
||||
public class LoginMBean {
|
||||
|
||||
private String Password;
|
||||
private String msg;
|
||||
private String userName;
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return Password;
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String pwd) {
|
||||
this.Password = pwd;
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void login() {
|
||||
FacesMessage message = null;
|
||||
boolean loggedIn = false;
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String user) {
|
||||
this.userName = user;
|
||||
}
|
||||
|
||||
// validate login
|
||||
public String validateUsernamePassword() {
|
||||
// TODO: Validar login
|
||||
boolean valid = this.userName.startsWith("a");
|
||||
if (valid) {
|
||||
if (username != null && username.equals("admin") && password != null && password.equals("admin")) {
|
||||
loggedIn = true;
|
||||
HttpSession session = SessionUtils.getSession();
|
||||
session.setAttribute("username", userName);
|
||||
return "home";
|
||||
session.setAttribute("username", username);
|
||||
session.setAttribute("userid", "1");
|
||||
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", username);
|
||||
} else {
|
||||
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,
|
||||
"Usuario o contraseña incorrecta", "Por favor, intentalo de nuevo"));
|
||||
return "login";
|
||||
loggedIn = false;
|
||||
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||
}
|
||||
|
||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
||||
}
|
||||
|
||||
// logout event, invalidate session
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -18,8 +18,8 @@ import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "SystemAdminMBean")
|
||||
@SessionScoped
|
||||
@Named("SystemAdminMBean")
|
||||
@RequestScoped
|
||||
public class SystemAdminMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -44,8 +44,7 @@ public class SystemAdminMBean implements Serializable {
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (SystemAdminFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.SystemAdminFacadeRemote");
|
||||
remoteManager = (SystemAdminFacadeRemote) ctx.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.SystemAdminFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
@@ -18,8 +18,8 @@ import ejb.visit.VisitFacadeRemote;
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "SystemAdminMBean")
|
||||
@SessionScoped
|
||||
@Named("VisitMBean")
|
||||
@RequestScoped
|
||||
public class VisitMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -44,8 +44,7 @@ public class VisitMBean implements Serializable {
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (VisitFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.VisitFacadeRemote");
|
||||
remoteManager = (VisitFacadeRemote) ctx.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.VisitFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user