title: Sending JSF textbox value to a managed bean function as a parameter
body: <p>I have two textboxes and one submit button in my login.xhtml page. I also have a bean. Here are the codes:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
  &lt;h:head&gt;
      &lt;title&gt;Welcome to Online Banking&lt;/title&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;h:outputText value="Online Banking System Login" &gt;&lt;/h:outputText&gt;
      &lt;h:form&gt;
          &lt;h:panelGrid columns="2" border="1"&gt;
              &lt;h:outputText value="Username:"&gt;&lt;/h:outputText&gt;
              &lt;h:inputText id="username" value="#{loginBean.username}"&gt;&lt;/h:inputText&gt;
              &lt;h:outputText value="Password"&gt;&lt;/h:outputText&gt;
              &lt;h:inputSecret  id="password" value="#{loginBean.password}" &gt;    &lt;/h:inputSecret&gt;
              &lt;h:commandButton value="Login" action="#{loginBean.loginCheck(username, password)}"&gt;&lt;/h:commandButton&gt;
  
          &lt;/h:panelGrid&gt;
      &lt;/h:form&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the beans file:</p>
  
  <pre><code>/*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
  package beans;
  
  import javax.inject.Named;
  import javax.enterprise.context.Dependent;
  
  /**
   *
   * @author SUUSER
   */
  @Named(value = "loginBean")
  @Dependent
  
  public class LoginBean {
  
  /**
   * Creates a new instance of LoginBean
   */
  public LoginBean() {
  }
  
  private static String username="", password="";
  
  public String getUsername(){
      return username;
  }
  public String getPassword(){
      return password;
  }
  public void setUsername(String Username){
      username=Username;
  }
  public void setPassword(String Password){
      password=Password;
  }
  
  public void loginCheck(String username, String password){
  
  
  }
  }
  </code></pre>
  
  <p>I will do the database check in my loginCheck function, so i need to pass the values of those two textboxes as a parameter. But i do not know how to do this. I just tried the code  but it just passes empty strings as parameteres. Can anyone help me with this?</p>
  
  <p>Thanks </p>