1 2 Previous Next 19 Replies Latest reply on Dec 21, 2009 3:40 PM by rmrui Go to original post
      • 15. Re: Bypassing validations when using EntityQuery
        dan.j.allen

        I just checked the code to add the boolean attribute validateModel to <param>. When set to false, the model validations (Hibernate Validator constraints) will not be applied. The default value is true.


        Here is an example:


        <page view-id="/UserSearch.xhtml">
            <param name="username" value="#{userQuery.user.username}" validateModel="false"/>
        </page>



        Please speak up here if you would like to see different name for this attribute.


        Btw, I also fixed the issue that the resource bundle was not being used to create the validation failed message and that it wasn't indicating which parameter was invalid.

        • 16. Re: Bypassing validations when using EntityQuery
          joblini

          Hi Dan, great to see that you fixed page parameters for this!


          When one wants to move beyond the capabilities of EntityQuery, a Hashmap offers more flexibility.  For example, we have extended EntityQuery to use the Hibernate Criteria API, and our example bean needs to accept input which includes wildcards and logical operators.  So each input field must be a String, regardless of how the type is defined on the Entity.

          • 17. Re: Bypassing validations when using EntityQuery

            Ingo Jobling wrote on Apr 09, 2009 03:25:


            Just replace the example bean with a Hashmap, as suggested by the previous poster.



            A DTO is a DTO, it does not matter if it is a Hashmap, or a handwritten class.

             

            Why does Seam Gen generate code that is so obviously wrong?


            • 18. Re: Bypassing validations when using EntityQuery

              Ingo Jobling wrote on Apr 12, 2009 20:44:


              Hi Dan, great to see that you fixed page parameters for this!



              Yes, I can not wait to see this fix released ;-)



              When one wants to move beyond the capabilities of EntityQuery, a Hashmap offers more flexibility.



              But it also offers a lot less control. Some customers will really get angry at you because they do not like to be able to write letters to search by a numeric field. Or search by a date field with something that does not even remotely seem to be a date.



              For example, we have extended EntityQuery to use the Hibernate Criteria API, and our example bean needs to accept input which includes wildcards and logical operators.



              Be careful, you could be opening the door for SQL injection.



                So each input field must be a String, regardless of how the type is defined on the Entity.



              But then how do you handle Date or Integer or BigDecimal fields? Just as strings? Then it is write to search for all products with price AQB ;-) ? For numeric fields you may want to offer ranges (greater than, less than), for dates you will want to offer between, but you will want to control the format (how the date is written). You can of course, embed this information in to the JSF tags, but... isn't that a violation of DRY?



              I think we should have components in seam that somehow used reflection to get information from the entity and use it to generate the right UI, but at the same time with the flexibility to send the information in to the Hashmap, to allow for flexibility... maybe with separated read bindings and write bindings ?





              • 19. Re: Bypassing validations when using EntityQuery
                rmrui

                Dan Allen wrote on Apr 09, 2009 07:56:


                I just checked the code to add the boolean attribute validateModel to <param>. When set to false, the model validations (Hibernate Validator constraints) will not be applied. The default value is true.


                Great job, Dan. Thanks!

                1 2 Previous Next