5 Replies Latest reply on Dec 6, 2008 5:56 AM by Ingo Jobling

    Seam gen crud and hibernate validator

    Ronaldo Campos Newbie


      I generated a seam crud aplication using seam gen and it´s working fine, but i am facing one problem:

      In every List page seam gen creates a search form for the entity. My entitys are annoted with Hibernate Validator (like email validation) and in my search form these validations are been executed. In the search form i have no s:validate ou s:validateAll, it shouldn´t execute this validation at this point. It forces me to write a valid email to search for it, where I would like to inform just part of it...

      Is this normal? How can I keep the validation on the create/update but skip it on the search form.

      I am using Seam 2.1.0 on Tomcat 6


        • 1. Re: Seam gen crud and hibernate validator
          Juan Pablo Gardella Newbie

          See section 6.5. Conversion and Validation of Seam reference. It says:

          --Even better, model-based Hibernate validator annotations are automatically recognized and validated.

          When type conversion or validation fails, a global FacesMessage is added to the FacesContext.--

          If you propagate a parameter, is automatically recognized and validated. I not found a solution, so I remove Hibernate validator annotations.

          Sorry my English.

          • 2. Re: Seam gen crud and hibernate validator
            Ronaldo Campos Newbie

            Hi Juan,

            Thanks for the awnser! I read the docs, took me to that conclusion too...
            Im my opinion it should be validated only where seam validate tag is seted. If a remove HibernateValidator annotations I'll have to validate everything on my own :(. I hope there is some workaround to this situation.

            If someone have faced the same problem that us and managed to solve in some other way, please post the solution.


            • 3. Re: Seam gen crud and hibernate validator
              Diego Coronel Apprentice

              Are you sure you are not using s:decorate with s:validate inside ? can you post your xhtml ?

              • 4. Re: Seam gen crud and hibernate validator
                Ronaldo Campos Newbie

                Hi Diego,

                Yes, i'm sure. In the seam crud the s:validate is used in the edit.xhtml template. The search form uses the display.xhtml template.

                Here is the search form:

                <h:form id="produtoSearch" styleClass="edit">
                    <rich:simpleTogglePanel label="Produto Search Filter" switchType="client" style="width:600px;">
                        <s:decorate template="../../layout/display.xhtml">
                            <ui:define name="label">Nome</ui:define>
                            <h:inputText id="nome" value="#{produtoList.produto.nome}"/>
                        <s:decorate template="../../layout/display.xhtml">
                            <ui:define name="label">Info</ui:define>
                            <h:inputText id="info" value="#{produtoList.produto.info}"/>
                    <div class="actionButtons">
                        <h:commandButton id="search" value="Search" action="/admin/produto/ProdutoList.xhtml"/>
                        <s:button id="reset" value="Reset">
                            <f:param name="info"/>
                            <f:param name="nome"/>

                And the template display.xhtml:

                <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                    <div class="prop">
                        <span class="name">
                            <ui:insert name="label"/>
                        <span class="value">

                These pages were created by seam gen, i just added the hibernate validator annotations and adjusted the layout.

                Thanks for your help! If you see some error please tell me.

                • 5. Re: Seam gen crud and hibernate validator
                  Ingo Jobling Master

                  Hi Ronaldo,

                  This is a known bug, see BypassingValidationsWhenUsingEntityQuery :

                  These are the conclusions I have drawn :

                  - Until this is fixed, the only way to use EntityQuery with Hibernate validations is to modify the EntityQuery subclass generated by Seam, replacing the example entity with a Hashmap

                  - Vote on the Jira issue here

                  - When one feature is so obviously incompatible with another, it does not reflect well on the framework.  I for one was somewhat embarrassed to be preaching how great Seam is to my colleagues, who then encountered this bug in their first hours of trying out Seam.

                  - Hope that the Seam developers realize how ridiculous this is. I think we all want Seam to be widely accepted, this doesn't help.