java - Sessionscoped managed bean not saving variables jsf -


i have bit strange problem managed session scoped bean. quite new jsf , looking strange. case is: loginbean stores variables initialized after successful login. @ first time, initialized, after successful login, user redirected profile.xhtml page, in call these variables loginbean. in page variables loginbean null. lose data after redirection.

loginbean:

package beans;  import facades.contactfacade; import facades.usersfacade; import java.io.serializable; import javax.ejb.ejb; import javax.faces.bean.managedbean; import javax.faces.bean.sessionscoped; import model.contact;  @managedbean(name="loginbean") @sessionscoped  public class loginbean implements serializable{     @ejb     private contactfacade contactfacade;     @ejb     private usersfacade usersfacade;  private string name; private string password; private int contactid; private contact contact;  public loginbean() {  }  public contact getcontact() {     return contact; }  public void setcontact(contact contact) {     this.contact = contact; } public string getname() {     return name; }  public void setname(string name) {     this.name = name; }  public string getpassword() {     return password; }  public void setpassword(string password) {     this.password = password; } public int getcontactid() {     return contactid; }  public void setcontactid(int contactid) {     this.contactid = contactid; }  private boolean checkvalidity(){     return (             (getname()!=null&&getname().length()>0)             &&(getpassword()!=null&&getpassword().length()>0))             ?true:false; } public string login(){     if(checkvalidity()&&usersfacade.trylogin(getname(), getpassword())){         setcontactid(usersfacade.getcontactid(getname()));          getcontactinstance();         return "profile.xhtml?faces-redirect=true";     }else{         return "loginerror.xhtml?faces-redirect=true";     } }  private void getcontactinstance(){     setcontact(contact);     this.contact=contactfacade.getcontact(getcontactid()); }   public string getdepartment(){     return contactfacade.getdepartmentname(getcontact().getdepartment()); } } 

profile.xhtml jsf

<h:form>         <h2>my information</h2>         <h:panelgrid columns="2">             <h:outputlabel value="name:"/>             <h:outputlabel value="#{loginbean.contact.name}"/>              <h:outputlabel value="lastname:"/>             <h:outputlabel value="#{loginbean.contact.lastname}"/>              <h:outputlabel value="address:"/>             <h:outputlabel value="#{loginbean.contact.address}"/>              <h:outputlabel value="telephone:"/>             <h:outputlabel value="#{loginbean.contact.telephone}"/>              <h:outputlabel value="email:"/>             <h:outputlabel value="#{loginbean.contact.email}"/>              <h:outputlabel value="department:"/>             <h:outputlabel value="#{loginbean.department}"/>              <h:commandbutton id="btnchange" value="change info" />           </h:panelgrid>      </h:form> 

this quite strange me. can help? in advance

can have overridden bean in faces-cofig.xml? if bean defined in xml higher priority , annotation ignored.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -