validate-model="false" in someSearchFacelet.page.xml doesn't work?
mgvanbochove Dec 31, 2012 10:28 AMHello Seam 2.3 users,
I'm converting my seam 2.2 application to seam 2.3 and I'm almost finished.
There's only 1 problem I can't solve yet: disabling jsr 303 bean validation for my search facelets.
Bean validation is great, but for searching to entities you want to reuse your jsr303 annotated pojo's, but without the bean validation:
example:
I want to search for persons by firstName, so I only enter the firstName, without the also required lastName. The search isn't executed, because bean validation says the required field lastName is empty.
There are a lot JSF users with the same problem:
http://stackoverflow.com/questions/5997847/bypass-bean-validation-in-jsf2
http://stackoverflow.com/questions/7709098/how-to-disable-the-entire-bean-validation-in-jsf?rq=1
http://stackoverflow.com/questions/12411317/how-to-disable-bean-validation-dynamically
http://stackoverflow.com/questions/4852496/jsf-2-0-how-to-skip-jsr-303-bean-validation?rq=1
http://www.coderanch.com/t/481100/JSF/java/Saving-form-validation
http://stackoverflow.com/questions/2332713/temoporarily-suppress-beanvalidation-with-jsf
The solutions found in the forums (<f:validateBean disabled="true" />) don't work, because seam adds his own validators.
After spending a lot of time to search for a solution I discovered the validate-model attribute of a page.xml file and the validateModel attribute of a param element inside a page element. I didn't find documentation about this attributes, but I understand it's a way to disable bean validation for some pages which is exactly what I need! Unfortunately the solution doesn't work.
I checked out the seam 2.3 branch from the git repository and started debugging. I found out that the attributes are read correctly from the page.xml files, but it seems like they aren't used in the application.
This class is always validating the model without looking at the value of the validateModel attribute:
org.jboss.seam.ui.validator.ModelValidator
The jboss-seam project contains this class and method:
org.jboss.seam.navigation.Param.validateConvertedValue(FacesContext facesContext, Object value)
but when setting a breakpoint inside this method I found out the code isn't executed. There is a TODO at line 256 referring to the ModelValidator class.
I've a couple of questions
- Is the validate-model attribute and validateModel attribute the way to disable bean validation for some page or param? It looks like a very elegant way to disable builtin validation.
- Should f:validateBean disabled="true" work in a seam application
- Did I find a bug?
I'm very happy with the new seam 2.3 version and it's important for me I can still use Seam in a JEE6, JSF2 and JPA2 environment and of course with JBoss 7.1.
Many thanks!
Regards,
Marnix van Bochove