6 Replies Latest reply on Feb 18, 2008 9:25 AM by Peter Boevink

    Bypassing validations when using EntityQuery with example ob

    Stuart Robertson Novice

      I'm using the EntityQuery framework class, and it's working fine. As per the seam docs I'm using the Example object to hold query parameters. It works very well.

      BUT, Seam is running the validations on the example object, validation fails, and the search can't proceed. While the entity validations are appropriate for persisting the entity (name must be at least 3 chars for instance), they don't apply to this use case.

      I'm not using s:validate or s:validateAll, which I thought was what triggered this behavior. Any suggestions? Is this how it is supposed to be?

      Thanks,

      Stu

        • 1. Re: Bypassing validations when using EntityQuery with exampl
          Pete Muir Master

           

          I'm not using s:validate or s:validateAll, which I thought was what triggered this behavior. Any suggestions? Is this how it is supposed to be?


          No, its not. Validation is triggered in two places with Seam. (1) s:validate(All), (2) by hibernate when persisting an entity.

          Are you sure you don't have any validators being applied e.g. in s:decorate templates?

          • 2. Re: Bypassing validations when using EntityQuery with exampl
            Peter Boevink Newbie

            I've exactly the same problem.
            The default display decorator is used as generated by seam-gen.
            A userLsit (entityQuery) is also generated by seam-gen.

            I would like to search for a user by e-mail address, but validation is performed (must be a well-formed email address) since there exists an @Email annotation on this attribute within the entity class.

            How to solve this?

            • 3. Re: Bypassing validations when using EntityQuery with exampl
              Stuart Robertson Novice

              Pete was exactly right in my case. I was using the edit.xhtml template that did validation. For search fields you shouldn't use your edit template.

              • 4. Re: Bypassing validations when using EntityQuery with exampl
                Peter Boevink Newbie

                Strange because I am using the display template....

                I'm using the templates and views as generated by seam-gen and can't get it working....

                • 5. Re: Bypassing validations when using EntityQuery with exampl
                  Stuart Robertson Novice

                  Hmm, that is odd. Can you post the relevant portions of your xhtml and also your template?

                  • 6. Re: Bypassing validations when using EntityQuery with exampl
                    Peter Boevink Newbie

                    UserList.xhtml as generated:

                    <!DOCTYPE composition 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:s="http://jboss.com/products/seam/taglib"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:a="http://richfaces.org/a4j"
                     xmlns:rich="http://richfaces.org/rich"
                     template="/layout/template.xhtml">
                    
                    <ui:define name="body">
                    
                     <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
                    
                     <h:form id="userSearch" styleClass="edit">
                    
                     <rich:simpleTogglePanel label="User search parameters" switchType="ajax">
                    
                     <s:decorate template="/layout/display.xhtml">
                     <ui:define name="label">username</ui:define>
                     <h:inputText id="username" value="#{userList.user.username}"/>
                     </s:decorate>
                    
                     <s:decorate template="/layout/display.xhtml">
                     <ui:define name="label">email</ui:define>
                     <h:inputText id="email" value="#{userList.user.email}"/>
                     </s:decorate>
                    
                     </rich:simpleTogglePanel>
                    
                     <div class="actionButtons">
                     <h:commandButton id="search" value="Search" action="/system/UserList.xhtml"/>
                     </div>
                    
                     </h:form>
                    
                    <------SNIP------>
                    



                    template (template.xhtml):
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:s="http://jboss.com/products/seam/taglib">
                    <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                     <title>MyTitle</title>
                     <link href="#{facesContext.externalContext.requestContextPath}/stylesheet/theme.css" rel="stylesheet" type="text/css" />
                    </head>
                    
                    <body>
                     <div class="header">
                     <ui:include src="hmenu.xhtml">
                     <ui:param name="projectName" value="MyProject"/>
                     </ui:include>
                     </div>
                     <div class="menu">
                     <ui:include src="vmenu.xhtml"/>
                     </div>
                     <div class="content">
                     <ui:insert name="body"/>
                     </div>
                    
                     <div class="footer">
                     Powered by <a href="http://jboss.com/products/seam">Seam</a>.
                     Generated by seam-gen.
                     </div>
                    
                    </body>
                    </html>
                    



                    Decoration (display.xhtml):
                    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:s="http://jboss.com/products/seam/taglib">
                    
                     <div class="prop">
                     <span class="name">
                     <ui:insert name="label"/>
                     </span>
                     <span class="value">
                     <ui:insert/>
                     </span>
                     </div>
                    
                    </ui:composition>
                    


                    I'm totally stuck, so I'm glad you want to take a look at it.....