From 2fe4176ef900df945077c9931f4dde3a6677cf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garcia=20Nu=C3=B1ez?= Date: Sat, 28 Dec 2019 15:12:00 +0100 Subject: [PATCH] Cambios menores en vista home y managed Bean pasado a ViewScoped. --- 1.sources/MyHealth/docroot/home.xhtml | 29 ++---------------- .../src/managedbean/common/homeMBean.java | 30 +++++++++---------- 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/1.sources/MyHealth/docroot/home.xhtml b/1.sources/MyHealth/docroot/home.xhtml index 9384fd0..b2ce987 100644 --- a/1.sources/MyHealth/docroot/home.xhtml +++ b/1.sources/MyHealth/docroot/home.xhtml @@ -8,6 +8,9 @@
+
+ Logeado como: +
@@ -22,32 +25,6 @@
- -
-
- - -
-
-
- -
- - -
-
- -
- -
-
- -
- -
- - -
diff --git a/1.sources/MyHealth/src/managedbean/common/homeMBean.java b/1.sources/MyHealth/src/managedbean/common/homeMBean.java index 89a2b55..216a2eb 100644 --- a/1.sources/MyHealth/src/managedbean/common/homeMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/homeMBean.java @@ -4,8 +4,8 @@ import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; -import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; +import javax.faces.view.ViewScoped; import javax.inject.Named; import common.UserType; @@ -16,22 +16,23 @@ import common.UserType; * */ @Named("home") -@RequestScoped +@ViewScoped public class homeMBean extends ManagedBeanBase implements Serializable { private static final long serialVersionUID = 1L; private boolean isLogedIn; private String userId; private String userName; + private String userDisplayName; private UserType userType; - private int refresh; @PostConstruct public void init() { - isLogedIn = SessionUtils.isLogedIn(); - userName = SessionUtils.getUserName(); - userId = SessionUtils.getUserId(); - userType = SessionUtils.getUserType(); + this.isLogedIn = SessionUtils.isLogedIn(); + this.userName = SessionUtils.getUserName(); + this.userDisplayName = SessionUtils.getUserDisplayName(); + this.userId = SessionUtils.getUserId(); + this.userType = SessionUtils.getUserType(); FacesMessage message = SessionUtils.getMessage(); @@ -54,6 +55,13 @@ public class homeMBean extends ManagedBeanBase implements Serializable { else return this.userName; } + + public String getUserDisplayName() { + if (this.isLogedIn == false) + return "Invitado"; + else + return this.userDisplayName; + } public String getUserId() { return this.userId; @@ -63,14 +71,6 @@ public class homeMBean extends ManagedBeanBase implements Serializable { return this.userType.getUserTypename(); } - public int getRefresh() { - return refresh; - } - - public void setRefresh(int refresh) { - this.refresh = refresh; - } - public boolean isPatient() { return (this.userType == UserType.PATIENT); }