title: Form validation in JSF
body: <p>I'm trying to validate a form before submitting, but is not working as expected. </p>
  
  <p>Here my XHTML</p>
  
  <pre><code>&lt;h:outputLabel for="name"&gt;Name: &lt;/h:outputLabel&gt;
  &lt;p:inputText id="name"  value="#{partyCreationBean.name}" /&gt;
  &lt;h:message for="name"/&gt;
  &lt;h:outputLabel for="symbol"&gt;Symbol: &lt;/h:outputLabel&gt;
  </code></pre>
  
  <p>Here my webBean:</p>
  
  <pre><code>@ManagedBean(name = "partyCreationBean")
  @RequestScoped
  public class PartyCreationBean {
  
      @EJB
      PartyManagerLocal ejb_partymanager;
      @EJB
      AuthenticationManagerLocal ejb_user;
  
      private PartyDTO party = new PartyDTO();
  
      public String getName() {
          return party.getName();
      }
  
      public void setName(String name) {
          party.setName(name);
  }
  </code></pre>
  
  <p>Here my DTO:</p>
  
  <pre><code>import org.hibernate.validator.constraints.*;
  
  public class PartyDTO implements IDataTransferObject {
      private Integer id;
      @NotEmpty()
      private String name;
  
      //Getters, setters and other stuff.
  }
  </code></pre>
  
  <p>Now the point is that if I leave "Name" empty and I press the button to create my party, the page just remain all the sames, and i get  Exceptions in the console stack traces (a lot like usual :D ) </p>
  
  <p>I tried to work with this XHTML (adding require="true"):</p>
  
  <pre><code>&lt;h:outputLabel for="name"&gt;Name: &lt;/h:outputLabel&gt;
  &lt;p:inputText id="name" required="true" value="#{partyCreationBean.name}" /&gt;
  &lt;h:message for="name"/&gt;
  &lt;h:outputLabel for="symbol"&gt;Symbol: &lt;/h:outputLabel&gt;
  </code></pre>
  
  <p>and it is working well but I want to put my "constraints" in the DTO level... </p>
  
  <p>Thanks in advance :)</p>