Disable POJO validation in seam-gen generated List page

By | June 26, 2009

Jboss seam-gen utility generates for every entity a default page EntityList.xhtml with great filtering, searching and scrolling capabilities. The searching functionality works like Query By Example, the well known concept widely used in old environments like Oracle Forms or Informix-4GL. The Jboss seam-gen utility uses the generic class EnityQuery and the POJO class as a search pattern. Until the release 2.1.2 of Jboss-Seam it was not possible to use POJO’s annotated with Hibernate Validator annotations as a search pattern, because seam wanted to validate the POJO before sending it to the EntityQuery class. Fortunately the Jboss-Seam 2.1.2 GA gives us the possibility to disable the validation of POJO model and makes this great functionality usable for the real world.
The model validation can be disabled at the page level, so edit the corresponding page definition file EntityList.page.xml and set validateModel property to false for fields you don’t want to be validated:

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">

   <param name="firstResult" value="#{customerList.firstResult}"/>
   <param name="sort" value="#{customerList.orderColumn}"/>
   <param name="dir" value="#{customerList.orderDirection}"/>
   <param name="logic" value="#{customerList.restrictionLogicOperator}"/>

   <param name="from"/>
   <param name="city" value="#{customerList.customer.city}" validateModel="false"/>
   <param name="code" value="#{customerList.customer.code}" validateModel="false"/>
   <param name="country" value="#{customerList.customer.country}"/>
   <param name="name" value="#{customerList.customer.name}" validateModel="false"/>
   <param name="street" value="#{customerList.customer.street}" validateModel="false"/>
   <param name="zip" value="#{customerList.customer.zip}" validateModel="false"/>


Unfortunately, this new feature is not reflected in the new seam-gen logic, so you must apply it manually if you want.