2 Replies Latest reply on Apr 7, 2008 11:17 PM by wiggy

    problem with seam validator on dates

    wiggy

      I cant get the seam convertDateTime to work.


      I have a simple form control declared as follows



      
      ...
      
                 <s:decorate id="dateOfBirthDecoration" template="layout/edit.xhtml">
      
                      <ui:define name="label">Date Of Birth</ui:define>
      
                      <h:inputText id="dateOfBirth" 
      
                                   value="#{person.dateOfBirth}">
      
                              <s:convertDateTime  type="date" dateStyle="medium"  pattern="dd/mm/yyyy" />
      
                         </h:inputText>     
      
                  </s:decorate>     
      
      ...
      
      
      



      in the backing entity I have a definition as follows


      
      
      ..
      
           public GregorianCalendar getDateOfBirth()
      
           {
      
                return dateOfBirth;
      
           }
      
      
           public void setDateOfBirth(GregorianCalendar dateOfBirth)
      
           {
      
                this.dateOfBirth = dateOfBirth;
      
           }
      
      
      
      ...
      
      



      when i fill in a date line


      20\10\1962  i get a seam validation faiure like this


      
      
      person.xhtml @55,60 value="#{person.dateOfBirth}": java.lang.IllegalArgumentException: argument type mismatch
      
      
      



      Bit unclear from the seam documentation as to what this should look like - however i think i had it right - but clearly not. 


      how do i get the format to accept the DD\MM\YYYY input format ?




        • 1. Re: problem with seam validator on dates
          tom_goring

          I think your backing bean field needs to be of type java.util.Date not GregorianCalendar.

          • 2. Re: problem with seam validator on dates
            wiggy

            thanks, just found that out for myself in trial and error.


            query if you want the seam validator to work with other date/calendar formats (java.sql.Date - avoid use of @Temporal for example, or GregorianCalendar) how should that be done or is this into writing the custom validator code - I havent got the expertise right now to get into that


            Thanks for the prompt response