Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have this in my GWT.XML file :</p> <pre><code>&lt;inherits name="org.hibernate.validator.HibernateValidator" /&gt; &lt;replace-with class="com.example.client.MyValidatorFactory"&gt; &lt;when-type-is class="javax.validation.ValidatorFactory" /&gt; &lt;/replace-with&gt; </code></pre> <p>I defined MyValidatorFactory like this :</p> <pre><code>public final class MyValidatorFactory extends AbstractGwtValidatorFactory { /** * Validator marker for the Validation Sample project. Only the classes * listed in the {@link GwtValidation} annotation can be validated. */ @GwtValidation(value = { Customer.class, License.class, Account.class }) public interface MyValidator extends Validator { } @Override public AbstractGwtValidator createValidator() { return GWT.create(GwtValidator.class); } } </code></pre> <p>In my classpath I have :</p> <pre><code>hibernate-validator-4.2.0.Final-sources.jar hibernate-validator-4.2.0.Final.jar </code></pre> <p>Now you can validate your domain objects :</p> <pre><code> Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); Set&lt;ConstraintViolation&lt;Account&gt;&gt; violations = validator.validate(account); </code></pre> <p>And the same validation then <strong>also works server-side</strong> :</p> <pre><code>private static ValidatorFactory factory = Validation.byDefaultProvider().configure().buildValidatorFactory(); Set&lt;ConstraintViolation&lt;DomainResource&gt;&gt; violations = factory.getValidator().validate(account); </code></pre> <p>Good stuff!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload