[jboss-user] [JBoss Seam] - s:validateAll PersistentClassConstraint
marthoff
do-not-reply at jboss.com
Thu Aug 23 04:36:47 EDT 2007
Hello,
I have a problem when using a Hibernate Validator with PersistentClassConstraint and the s:validateAll Tag.
When accessing a property of a class which uses this validator within a JSF Page an error occurs due that the Validation Exception is not handled by the s:validateAll Tag. The exception is thrown when the entityManager tries to commit the entity.
Is there a way to validate the whole entity before commiting?
I tried to solve the problem by using a custom JSF validator but in that case it seams that I'm losing some state, because the EntityHome instance returns false for the mehod isManaged after a wrong validation.
I'm using jBoss SEAM 1.2.1.GA and code generated by "seam generate-entities".
The custom hibernate validator annotation:
| @ValidatorClass(SerialValidator.class)
| @Target(value = ElementType.TYPE)
| @Retention(RetentionPolicy.RUNTIME)
| @Documented
| public @interface Serial {
| String message() default "Wrong Serial";
| }
|
The entity class:
| @Entity
| @Table(name = "machine")
| @Name("machine")
| @Serial
| public class Machine implements java.io.Serializable
| ...
|
JSF code of one property, which is checked by the validator:
| <s:decorate id="serialDecoration" template="/layout/edit.xhtml">
| <ui:define name="label">#{messages.serial}</ui:define>
| <h:inputText id="serial" value="#{machineHome.instance.serial}"
| required="true">
| <a:support event="onblur" reRender="machine" />
| </h:inputText>
| </s:decorate>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077187#4077187
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4077187
More information about the jboss-user
mailing list