Cambios menores en vista home y managed Bean pasado a ViewScoped.

This commit is contained in:
Marcos Garcia Nuñez
2019-12-28 15:12:00 +01:00
parent 308fa17eba
commit 2fe4176ef9
2 changed files with 18 additions and 41 deletions

View File

@@ -8,6 +8,9 @@
<h:form>
<p:panel header="Pagina principal">
<div class="ui-g ui-fluid">
<div class="ui-g-12 ui-md-12">
Logeado como: <h:outputLabel value="#{home.userDisplayName}" style="font-weight: bold;" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel for="selectorTema" value="Cambio de tema" />
</div>
@@ -22,32 +25,6 @@
<p:commandButton value="Usar tema" update="messages" action="#{sessionPreferences.updateCurrentTheme}" icon="pi pi-save" />
</div>
<div class="ui-g-5 ui-md-5" />
<div class="ui-g-2 ui-md-2">
<div class="ui-inputgroup">
<p:calendar pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
<p:commandButton value="Fecha" />
</div>
</div>
<div class="ui-g-10 ui-md-10" />
<div class="ui-g-2 ui-md-2">
<h:outputLabel value="Fecha" />
<p:calendar pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
</div>
<div class="ui-g-10 ui-md-10" />
<div class="ui-g-12">
<h:outputLabel value="Rich Text Editor" />
</div>
<div class="ui-g-12 ui-md-12">
<p:editor />
</div>
<div class="ui-g-12 ui-md-12">
<h:outputLabel value="Logeado como:" />
<p:inputText readonly="true" value="#{home.userName}" />
</div>
</div>
</p:panel>
</h:form>

View File

@@ -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);
}