GWT: Get constants in server side

后端 未结 1 2018
一生所求
一生所求 2021-01-03 00:53

I\'m trying to get the constants (ConstantsWithLookup) stored in the client side in my server side, but it can\'t figure out how to do it. I have my constants interface and

相关标签:
1条回答
  • 2021-01-03 01:42

    I'm using Hermes with GWT 2.5.0.rc1, and it works fine. Usage:

    • put hermes-1.2.0.jar into war/WEB-INF/lib
    • Then on the server side write something like
    MyConstantsWithLookup my = Hermes.get(MyConstantsWithLookup.class, "de");
    String string = my.getString(key);
    
    • A properties file MyConstantsWithLookup.properties must exist in the same package as MyConstantsWithLookup.java, even if that properties file is empty (which might be the case if you're using @DefaultStringValue etc.)
    • Also add MyConstantsWithLookup_de.properties etc.
    • Make sure, that these properties files are copied next to your classes when compiling. Javac doesn't do that, so it must be done in an additional build step (Eclipse usually does this automatically, but it won't happen by itself when you build e.g. with Ant)
    • Many build setups will skip the java and properties files from the "client" package when compiling the server side. In that case, put your constants files in the "shared" package (if you have one).
    0 讨论(0)
提交回复
热议问题