[jboss-user] [JBoss Seam] - Custom validator disables hibernate default validator

dapeng do-not-reply at jboss.com
Mon Oct 29 13:20:56 EDT 2007


Hi,

on one column (property) of my entity, a unique constraint needs to be defined. To avoiding a duplication of this property, I implemented a custom validator method to check the uniqueness. So far it works fine. But I found out, that the default hibernate validator doesn't work anymore (have got a @Length (max=11)  annotation on the same property), as soon as the validator binding is added to the component, though the text field is put inside a validateAll tag.

<h:inputText id="vinPrefix" value="#{entity.vinPrefix}" required="true" label="#{masterDataMsgs['vingroup.edit.label.name']}" styleClass="text" rendered="#{entity.transient}" validator="#{vinGroupEditAction.checkVinPrefix}">
  | <a4j:support event="onblur" reRender="vinPrefixDecorate" />
  | </h:inputText>
  | 					 

After checking the source code, I found the following line in the method addValidators of ValidateAllRendererBase.java.

if ( evh.getValidators().length==0 && evh.getValidators().length == 0 )
  |             {
  |                evh.addValidator( new ModelValidator() );
  |             } 

First of all, I don't understand, why you check the same condition twice. Second, I have no clue, why you only add the ModelValidator, if here is no other validator. I would exactly like to combine the hibernate validator with my custom one. 

Any explanation is appreciated

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099934#4099934

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099934



More information about the jboss-user mailing list