麻烦与gwt验证

时间:2013-04-02 09:50:48

标签: validation gwt

我正在尝试使用新的 validation-api(1.1)和Hibernate验证器(5.0)来使用gwt valiation 模块(jsr303),但是,明显得到了

ERROR: Errors in 'file:/C:/projects/qiwi-digest/webui/trunk/src/main/java/ru/befree/qiwi/client/gin/SampleValidatorFactory.java'
  ERROR: Line 27: No source code is available for type javax.validation.ParameterNameProvider; did you forget to inherit a required module?
  ERROR: Line 27: The method getParameterNameProvider() of type SampleValidatorFactory must override or implement a supertype method
  ERROR: Line 28: No source code is available for type org.hibernate.validator.internal.engine.DefaultParameterNameProvider; did you forget to inherit a required module?
  ERROR: Line 32: The method close() of type SampleValidatorFactory must override or implement a supertype method

即。 GWT目前没有Validation API 1.1支持。

任何解决方法的想法?

2 个答案:

答案 0 :(得分:3)

你可能在使用Hibernate 5时处于领先地位!!!!

GWT仅支持hibernate 4.1.0.Final。这是来自GWT样本的Validation的剪辑maven pom.xml。

   <!-- Hibernate bean validation binary for the server -->

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.1.0.Final</version>
      <exclusions>
        <exclusion>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Hibernate bean validation source for the GWT client -->

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.1.0.Final</version>
      <classifier>sources</classifier>
      <exclusions>
        <exclusion>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

GWT已经移植了hibernate验证器代码以与客户端一起工作。你可以在这里找到它 - https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/org/hibernate/validator

你可以尝试黑客攻击hibernate 5和validation-api 1.1 !!!

答案 1 :(得分:1)

您是否在路径中添加了javax.validation-api源代码?如果您使用maven,您的依赖项应如下所示:

<dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>
  <classifier>sources</classifier>
  <scope>test</scope>
</dependency>