title: How to enforce jsf to create new instance of bean instead of throwing NullPointerException?
body: <p>I'm almost sure that I do something wrong and thus the question's title is a bit incorrect.</p>
  
  <p>I have a form with several fields for creating a new User-objects (fields like login, password, birthday etc). And I have 2 buttons - Cancel and Create. I didn't finish Create yet :) , but when I press Cancel I see NullPointerException. Here is simplified code: </p>
  
  <pre><code>&lt;f:view&gt;
      &lt;h:form&gt;
          &lt;h:panelGroup layout="block"&gt;       
              &lt;h:inputText id="add_login" value="#{userSupport.user.login}"/&gt;
              &lt;h:inputSecret id="add_password" value="#{userSupport.user.password}"/&gt;
              &lt;h:inputText id="add_name" value="#{userSupport.user.name}"/&gt;
              &lt;h:inputText id="add_surname" value="#{userSupport.user.surname}"/&gt;
  
              &lt;h:commandButton value="Cancel" action="cancel"/&gt;
          &lt;/h:panelGroup&gt;
      &lt;/h:form&gt;
  &lt;/f:view&gt;
  </code></pre>
  
  <p>UserSupport class has field <code>user</code> with getter and setter and some other methods. It's a Spring bean with Session scope. </p>
  
  <p>When I press cancel, I see NPE because jsf tries to save values from inputs in user-object, but user-object is null.</p>
  
  <p>What is the correct way of doing this?</p>