title: Passing parameters between managedbeans primefaces
body: <p>I have a problem with my managedbeans. I cannot manage to pass parameters between them. Here is an XHTML snippet. It is basically a form for login. It just sends the parameters to back bean.</p>
  
  <pre><code>&lt;h:outputLabel for="username" value="Kullanıcı Adı: *" /&gt;
    &lt;p:inputText id="username" value="#{loginBean.username}" required="true" requiredMessage="Kullanıcı adı giriniz."&gt;
      &lt;f:validateLength minimum="2" /&gt;
    &lt;/p:inputText&gt;
    &lt;p:message for="username" display="icon"/&gt;
    &lt;h:outputLabel for="password" value="Şifre: *" /&gt;
    &lt;p:inputText id="password" value="#{loginBean.password}" required="true" requiredMessage="Şifreyi giriniz!" type="password"&gt;
      &lt;f:validateLength minimum="2" /&gt;
    &lt;/p:inputText&gt;
    &lt;p:message for="password" id="msgPass" display="icon"/&gt;
    &lt;f:facet name="footer"&gt;
      &lt;center&gt;
        &lt;p:commandButton id="submit" value="Giriş" icon="ui-icon-check" action="#{loginBean.check}" style="margin:0" update="grid"/&gt;
      &lt;/center&gt;
    &lt;/f:facet&gt;
  </code></pre>
  
  <p>In my backing bean, I am checking whether the user input matches with the database record. If so then I let him enter the system. At the same time, I am taking his full name.</p>
  
  <p>My backbean:</p>
  
  <pre><code>@ManagedBean
  @RequestScoped
  public class LoginBean {
    public String getUsername() {
      return username;
    }
    public void setUsername(String username) {
      this.username = username;
    }
    public String getPassword() {
      return password;
    }
    public void setPassword(String password) {
      this.password = password;
    }
    public String getMgs() {
      return mgs;
    }
    public void setMgs(String mgs) {
      this.mgs = mgs;
    }
    public String getFullname() {
      return fullname;
    }
    public void setFullname(String fullname) {
      this.fullname = fullname;
    }
    public String getOriginalURL() {
      return originalURL;
    }
    public void setOriginalURL(String originalURL) {
      this.originalURL = originalURL;
    }
    private String username;
    private String password;
    private String mgs;
    private String fullname;
    private String originalURL;
    private static Logger log = Logger.getLogger(LoginBean.class.getName());
    public String check() throws Exception {
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/projetakip", "root", "");
      Statement stmt = con.createStatement();
      String md5Pass = md5(password);
      String SQL = "select * from users where username='" + username + "' and password='" + md5Pass + "'";
      ResultSet rs = stmt.executeQuery(SQL);
      while (rs.next()) {
        if (username.matches(rs.getString("username")) &amp;&amp; md5Pass.matches(rs.getString("password"))) {
          this.fullname = rs.getString("ad") + " " + rs.getString("soyad");
          return "panel?faces-redirect=true";
        } else {
          FacesMessage msg = new FacesMessage("Yanlış kullanıcı adı/şifre.");
          FacesContext.getCurrentInstance().addMessage(null, msg);
          return "index?faces-redirect=true";
        }
      }
      return "index?faces-redirect=true";
    }
    public void getProductSetupData(ActionEvent event) {
      FacesContext context = FacesContext.getCurrentInstance();
      Data data = context.getApplication().evaluateExpressionGet(context, "#{data}", Data.class);
    }
  </code></pre>
  
  <p>What I want is to pass <code>fullName</code> to other beans (or pages). How can I pass this variable between my beans?</p>
  
  <p>Thanks in advance.</p>