2 Replies Latest reply on Apr 7, 2009 9:31 AM by scott duke

    Bypassing validation on h:inputText

    scott duke Novice

      I have a uzerList.xhtml which performs a search. The h:inputText search fields are performing validations defined on the properties from the uzer entity. Is there a way to bypass the validation?


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      <ui:define name="body">
       <h:form id="uzerSearch" styleClass="edit">
       <rich:simpleTogglePanel label="User Search Parameters" switchType="ajax">
       <s:decorate template="/layout/display.xhtml">
       <ui:define name="label">Name</ui:define>
       <h:inputText id="name" value="#{uzerList.uzer.name}"/>
       <s:decorate template="/layout/display.xhtml">
       <ui:define name="label">Email</ui:define>
       <h:inputText id="email" value="#{uzerList.uzer.email}" immediate="true" required="false"/>
       <div class="actionButtons">
       <h:commandButton id="search" value="Search" action="/role/admin/UzerList.xhtml" />

      public class Uzer implements Serializable
       // seam-gen attributes (you should probably edit these)
       private Long id;
       private Integer version;
       // add additional entity attributes
       private String name;
       private String email;
       // seam-gen attribute getters/setters with annotations (you probably should
       // edit)
       @Column(name = FIELD_ID)
       public Long getId() {
       return id;
       public void setId(Long id) {
       this.id = id;
       @Column(name = FIELD_VERSION)
       public Integer getVersion() {
       return version;
       private void setVersion(Integer version) {
       this.version = version;
       @Length(min=1, max = 40)
       // @Pattern(regex = "[a-zA-Z]+", message =
       // "Last name must only contain letters")
       @Column(name = FIELD_NAME, nullable = false, length = 40)
       public String getName() {
       return name;
       public void setName(String name) {
       this.name = name;
       @Column(name = FIELD_EMAIL)
       public String getEmail() {
       return email;
       public void setEmail(String email) {
       this.email = email;

      When I press the search button on the xhtml, messages appear. One for the name field something like: "must be between 1 and 40" and one for the email with something like: "not a well formed email address". I do not want to validate on search parameters.

      How do I bypass this?

        • 1. Re: Bypassing validation on h:inputText
          Ilya Shaikovsky Master

          remove immediate = true from inputs and add to button.

          • 2. Re: Bypassing validation on h:inputText
            scott duke Novice

            Tried that. The messages are no longer showing, but when I try to search on email or name, the fields clear out and the search list does not change.

            I am using the searches similar to those described in "Seam in Action".


             <param name="from"/>
             <param name="company" value="#{uzerList.uzer.company}"/>
             <param name="name" value="#{uzerList.uzer.name}"/>
             <param name="email" value="#{uzerList.uzer.email}"/>
             <param name="phone" value="#{uzerList.phone.phoneNumber}"/>

            public class UzerList extends EntityQuery<Uzer>
             private static final long serialVersionUID = -7220659451427306516L;
             private static final String[] RESTRICTIONS = {
             "lower(uzer.company) like concat('%',lower(#{uzerList.uzer.company}),'%')",
             "lower(uzer.name) like concat('%',lower(#{uzerList.uzer.name}),'%')",
             "lower(uzer.email) like concat('%',lower(#{uzerList.uzer.email}),'%')",
             "lower(phone.phoneNumber) like concat('%',lower(#{uzerList.phone.phoneNumber}),'%')",
             private Uzer uzer = new Uzer();
             private Phone phone = new Phone();
             public UzerList() {
             this.setEjbql("select uzer, phone from Uzer uzer join uzer.phones phone");
             public Uzer getUzer() {
             return uzer;
             public Phone getPhone() {
             return phone;