java - GWT 在客户端使用 iban4j 进行验证

标签 java gwt

我需要首先在客户端验证来自 2 个文本框的用户输入,然后在服务器端验证。我在共享包中创建了一个名为 FieldVerifier 的类。 我有 2 种方法使用 iban4j 验证 IBAN 和 BIC:

public static boolean isValidIban(String iban) {
    try {
        IbanUtil.validate(iban, IbanFormat.Default);
    } catch (Exception exc) {

        return false;
    } 
    return true;
}

public static boolean isValidBic(String bic) {
    try {
        BicUtil.validate(bic);
    } catch (Exception exc) {
        return false;
    }
    return true;
}

但是如果我尝试启动应用程序,则会收到以下错误:

Line 91: No source code is available for type org.iban4j.IbanUtil; did you forget to inherit a required module?

Line 101: No source code is available for type org.iban4j.BicUtil; did you forget to inherit a required module?

Line 91: No source code is available for type org.iban4j.IbanFormat; did you forget to inherit a required module?

我需要做什么来构建这个库才能在客户端使用它?

最佳答案

您在共享目录中设置了 Validator 类。因此, validator 本身的代码可以在客户端使用,但依赖项(iban4j)也需要与 GWT 兼容才能包含在客户端。

要做你想做的事,你有两个选择。

  • 直接在共享目录中添加 iban4j 的代码 - 这意味着松开 iban4j 库的链接
  • 将 iban4j 转换为 GWT 模块。 (这是通过在 iban4j jar 中添加源代码和 Iban4j.gwt.xml 文件来完成的)并将模块包含到您的项目中 - 这意味着修改当前库或根据您的需要重新编译它

关于java - GWT 在客户端使用 iban4j 进行验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45933617/

相关文章:

Java Swing 计时器未启动?

java - GWT String.replace 不起作用

GWT Suggestbox在实例化后定义suggest oracle

java - 仅显示一次广告 View

java - 从实例初始值设定项更新静态最终字段

java - 使 Gradle 包含整个依赖树中的所有源

java - 如何断言 KeyPressEvent 是否是任何键盘字符?

gwt - 试图让 UIBinder 给我一个跨度而不是一个 div

java - Libgdx 序列化

Java 应用程序未关闭连接