Cambio en la descripción de PDS MyHealth a MyHealth

Configuración de regla de navegación para JSF.
Pruebas con primefaces
Nuevo ManagedBean para pantalla home.
Pagina de login para pruebas.
This commit is contained in:
mgarcianun
2019-11-22 18:37:20 +01:00
parent 12da362578
commit a7a7f99b3a
15 changed files with 128 additions and 52 deletions

View File

@@ -4,4 +4,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 14.0 Runtime"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib"/>
</classpath>

View File

@@ -1,6 +1,6 @@
<project name="MyHealth Web Application" default="all" basedir=".">
<description>PDS MyHealth</description>
<description>MyHealth</description>
<!-- definition of global property -->
<property environment="env" />

View File

@@ -1,3 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -6,8 +8,10 @@
<navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>admin</from-outcome>
<to-view-id>/admin.xhtml</to-view-id>
<from-outcome>home</from-outcome>
<to-view-id>/home.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

View File

@@ -30,14 +30,18 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/error.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>ErrowView.xhtml</location>
<location>/error.xhtml</location>
</error-page>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>HomeView.xhtml</welcome-file>
<welcome-file>home.xhtml</welcome-file>
</welcome-file-list>
</web-app>

View File

@@ -4,7 +4,8 @@
<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:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -15,12 +16,14 @@
<h:body>
<div id="layout">
<div id="top" class="top">
<h1 class="Titulo">myHealth page header</h1>
<h1 class="Titulo">myHealth Site</h1>
</div>
<hr />
<div id="menucontainer" class="estilomenu">
<p:spinner></p:spinner>
<h:form>
<p>Welcome #{login.userName}, <h:commandLink action="#{login.logout}" value="Logout"></h:commandLink></p>
<p>Welcome #{login.userName}, <h:commandLink action="#{login.logout}" value="Logout">Logout</h:commandLink></p>
</h:form>
</div>
<div id="content">

View File

@@ -1,23 +1,36 @@
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<f:metadata>
<f:viewParam name="refresh" value="#{specs.refresh}"/>
</f:metadata>
<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">
<f:metadata>
<f:viewParam name="refresh" value="#{specs.refresh}" />
</f:metadata>
<ui:composition template="./header.xhtml">
<ui:define name="content">
<h:form align="left" >
<div style="margin: auto; width: 800px">
<div style="display: inline; float: right;">
<!-- Crear menu de aplicación solo si estamos logeados -->
<h:form>
<p:panel header="Prueba con Primefaces">
<h:panelGrid columns="2">
<h:outputLabel value="Fecha" />
<p:calendar pattern="dd/MM/yyyy" />
</h:panelGrid>
</p:panel>
</h:form>
<h:form align="left">
<div style="margin: auto; width: 800px">
<div style="display: inline; float: right;">
<!-- Crear menu de aplicación solo si estamos logeados -->
</div>
<br />
<p:spinner />
<br /> Welcome #{home.userName}
<!-- Mostrar página de bienvenida -->
</div>
<br /><br />
<!-- Mostrar página de bienvenida -->
</div>
</h:form>
</h:form>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,15 +1,20 @@
<?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: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">
<h:head>
<title>login</title>
</h:head>
<ui:composition template="./header.xhtml">
<ui:define name="content">
<h:form>
<h3>myHealth login page</h3>
<h3>myHealth login</h3>
<h:outputText value="Por favor, introduzca su nombre de usuario y contraseña para acceder al sistema."></h:outputText>
<h:outputText value="Usuario:" />
<h:inputText id="Uusario" value="#{login.userName}"></h:inputText>
<h:message for="username"></h:message>

View File

@@ -16,7 +16,7 @@
</div>
</div>
<p align="center">
<h:button value="Volver al inicio" outcome="homeView?refresh=1" />
<h:button value="Volver al inicio" outcome="home?refresh=1" />
</p>
</h:form>
</ui:define>

View File

@@ -1,24 +0,0 @@
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="errorForm">
<div align="center">
<h1>test Page</h1>
<hr/>
<div>TestPage:</div>
<div>
test page content
</div>
</div>
<p align="center">
<h:button value="Volver al inicio" outcome="homeView?refresh=1" />
</p>
</h:form>
</ui:define>
</ui:composition>
</html>

View File

@@ -16,7 +16,7 @@
</div>
</div>
<p align="center">
<h:button value="Volver al inicio" outcome="homeView?refresh=1" />
<h:button value="Volver al inicio" outcome="home?refresh=1" />
</p>
</h:form>
</ui:define>

View File

@@ -0,0 +1,10 @@
package common;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.annotation.FacesConfig;
@FacesConfig
@ApplicationScoped
public class ApplicationConfig {
}

View File

@@ -0,0 +1,28 @@
package common;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@SuppressWarnings("deprecation")
@ManagedBean(name = "home")
@SessionScoped
public class homeMBean implements Serializable {
private static final long serialVersionUID = 1L;
public String getUserName() {
return SessionUtils.getSession().getAttribute("username").toString();
}
public String getUserId() {
return (String) SessionUtils.getSession().getAttribute("userid");
}
}

View File

@@ -0,0 +1,21 @@
package managedbean.profile;
import java.util.Properties;
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
public class ProfileMBeanBase {
@EJB
protected ProfileFacadeRemote remoteManager;
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");
}
}

11
2.database/.project Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>2.database</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>