title: Accessing bean properties in JSF 2.0
body: <p>I have the following model code, which I am supposed to use.</p>
  
  <pre><code>    public class Client extends User {
  
      private String userName;
  
      public Client(String firstName, String lastName, String userName){
          super(firstName, lastName);
          this.userName = userName;
      }
  
      //getters and setters
  }
  
  public abstract class User {
      String firstName;
      String lastName;
  
     //getters and setters
  }
  </code></pre>
  
  <p>Now I have created the following bean:</p>
  
  <pre><code>@ManagedBean(name = "client")
  @SessionScoped
  public class ClientBean implements Serializable {
  
      private final long serialVersionUID = 1L; 
      private Client client;
  
      public Client getClient(){
          return client;
      }
  
      public void setClient(Client client){
          this.client = client;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Now I want to set the clients' firstName using this bean in an xhtml page: </p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"&gt;
      &lt;head&gt;
          &lt;title&gt;Register as a client&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h:form&gt;
              First Name:&lt;h:inputText value="#{???}"&gt;&lt;/h:inputText&gt;
              &lt;br/&gt;                  
              &lt;h:commandButton value="Register" action="registered?faces-redirect=true"/&gt;
          &lt;/h:form&gt;
      &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>Now my question is: How do I access the clients' firstName? Am I supposed to create a new bean that represents user as well and extend it in ClientBean? (If so, what's the use of having model code at all? I would have double code everywhere?) Or is there any other simpler way to implement this in JSF 2.0?</p>