title: JSF 2 Submitting a form
body: <p>I have this Facelet codes:</p>
  
  <pre><code>&lt;h:inputText id="searchtext" value="#{SearchBean.input}" /&gt;
  &lt;h:commandButton value="#{msg.BUTTON_SEARCH_LABEL}" title="#{msg.BUTTON_SEARCH_LABEL}"
    action="#{SearchBean.Submit}" /&gt;
  </code></pre>
  
  <p><strong>SearchBean</strong> has the following:</p>
  
  <pre><code>@ManagedBean(name = "SearchBean")
  @RequestScoped
  public class SearchBean implements Serializable
  {
      private String input = null;
      private Boolean submitted = false; 
  
      public String getInput() {
         return input;
      }
  
      public boolean getSubmitted() {
         return submitted;
      }      
  
      public void setInput(String input) {
         this.input = input;
      }
  
      public void setSubmitted(Boolean submitted) {
         this.submitted = submitted;
      }
  
      public String Submit() {
         System.out.println("&gt;&gt;&gt; SUBMITTED &lt;&lt;&lt;"); 
         submitted = true;
         return "";
     }    
  }
  </code></pre>
  
  <p>The SearchBean's method is called in <strong>BookService</strong> bean as follow:</p>
  
  <pre><code>@Stateless
  public class BookService()
  {
      @Inject
      private SearchBean searchBean;
  
      @PostConstruct
      public void init()
      {
         Boolean isSearch = isSubmitted();
         if (isSearch) {
            // some codes
         } else {
            // other codes
         }
      }
  
      public Boolean isSubmitted() {
         System.out.println("STATUS: " + searchBean.getSubmitted()); 
         return searchBean.getSubmitted();
      }       
  }
  </code></pre>
  
  <p>When I submit the form, the status return by SearchBean's <strong>getSubmitted()</strong> method always return <strong>false</strong>. I would expect this to return <strong>true</strong> when the form is submitted. I don't know what to do.</p>
  
  <p>Is <strong>FlashScoped</strong> the only usable option with form submission in JSF 2? Any expert care to comment.</p>