0 Replies Latest reply on Mar 18, 2009 8:50 PM by sridhar kondoji

    validation errors with seam genereated CRUD app.

    sridhar kondoji Newbie
      Hi,
      I have used seam gen tool to generate entities first and then UI. However, i did modify the entity classes a lot to suit my requirements. Once, i was confortable and fixed all compile errors, i generated ui and exploded it to jboss 4.2.2 GA

      However, when i try to enter Gender form field (value 'male'), i am getting validation error that the length should be between 0 and 6. What is starange is that the value i enter is between 0 and 6 characters.

      What do you think iam doing wrong here?
      Either it should be an issue with EnumType.STRING and a mismatch with Schema in backend
      Or it should be something else i don't quiet understand.

      Here is the code snippet on length of gender field.
      a) xhtml code snippet
                  <s:decorate id="genderField" template="layout/edit.xhtml">
                      <ui:define name="label">Gender</ui:define>
                      <h:inputText id="gender"
                                value="#{userprofileHome.instance.gender}">
                          <a:support event="onblur" reRender="genderField" bypassUpdates="true" ajaxSingle="true"/>
                      </h:inputText>
                  </s:decorate>

      b) Entity class code snippet:
              @Enumerated(EnumType.STRING)
              @Column(name = "gender", length = 6)
              @Length(max = 6)
              public GenderType getGender()
              {
                      return this.gender;
              }
              public void setGender(GenderType gender)
              {
                      this.gender = gender;
              }

      c) enum snippet
      public enum GenderType
      {
              male,
              female
      }

      d) schema code snippet
      CREATE TABLE userprofile
      (
              id BIGINT NOT NULL,
              name TINYTEXT NOT NULL,
              gender ENUM ('male','female') NULL,
              lastupdated DATETIME NULL,
              PRIMARY KEY (id)
      );

      Even though iam entering the gender field with values 'male' or 'female', iam receiving length validation error 'length should be between 0 and 6 characters.
      Database is using utf8 encoding.

      Thank you
      sri