0 Replies Latest reply on Dec 1, 2011 9:51 AM by Pau aaa

    RichFaces 4.0.0.Final. JSR-303 Validation problems

    Pau aaa Newbie

      I have some concerns with the operation of the validation of RichFaces that meets the JSR-303. My application uses Spring 3.0.5, JSF 2 with Mojarra and RichFaces 4 and Hibernate 3.6.8.

       

      My xhtml file:

       

      <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition  
                xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
          <h:head></h:head>
          
                <h:form>
                          <rich:tabPanel id="tabPanel" selectedTab="fitxa" switchType="client" style="width:40%; margin-left:auto; margin-right:auto;">
        <rich:tab id="fitxa" name="Fitxa" rendered="#{crudBlogBean.tabFitxa}">
                                              <a4j:region>
                                                        <h:panelGrid columns="3" style="margin-left:auto; margin-right:auto;"> 
                                                                  <h:outputLabel value="Id: " />
                                                                  <h:inputText id="id" value="#{crudBlogBean.blog.id}" ><rich:validator /></h:inputText>
                                                                  <rich:message for="id" />
        
                                                                  <h:outputLabel value="Nom: " />
                                                                  <h:inputText id="nom" value="#{crudBlogBean.blog.nom}"><rich:validator  /></h:inputText>
                                                                  <rich:message for="nom" />
        
                                                                  <h:outputLabel value="Número: " />
                                                                  <h:inputText id="numero" value="#{crudBlogBean.blog.numero}"><rich:validator /></h:inputText>
                                                                    <rich:message for="numero" />
                                                           
                                                                    <a4j:commandButton execute="@region" actionListener="#{crudBlogBean.desar}" value="Acceptar" render="tabPanel" />
                                                                    <a4j:commandButton execute="@this" actionListener="#{crudBlogBean.tornar}" value="Tornar" render="tabPanel" />
                                                        </h:panelGrid>
                                              </a4j:region>
                                    </rich:tab>
                          </rich:tabPanel>
                </h:form>
      </ui:composition>
      

       

      My Blog Bean:

       

      @Entity
      @Table(name="Blogs")
      public class Blog {
                @Id 
                @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SQ_BLOG")
                @SequenceGenerator(name="SQ_BLOG", sequenceName="SQ_BLOGS", allocationSize = 1)
          private int id;
        
                @Size(min = 1, max = 15, message="{hola}")
          private String nom;
          
          private String descripcio;
          
          @Max(10)
          @NotNull
          private int numero = 0;
          
          @OneToMany(mappedBy="blog")
          private List<Article> articles;
      
      (get and set)
      
      }
      

       

      1. The validation works fine. My first question is, does the validator is instantiated by RichFaces? In my Spring configuration I have not added anything.

       

      2. In the example RichFaces documentation (here) at objects <rich:validator /> input is added, is it necessary?

       

      3. In the example above, on the onblur validation throws but does not launch in my exemple, only when I press the a4j: commandButton, why?

       

      4. Finally, I understand that the validator is managed by RichFaces, to change the default messages I've achieved putting in the root ValidationMessages.properties classhpath, is there any way to put that file anywhere?