/ / Jak odzyskać klucz / wartość JavaScriptObject w AbstractPresenterModule w GWTP? - java, javascript, gwt, gwtp, gwt-platform

Jak uzyskać klucz / wartość JavaScriptObject w module AbstractPresenterModule w GWTP? - java, javascript, gwt, gwtp, gwt-platform

Używam GWTP i chcę użyć Słownik w moim module AbstractPresenterModule. Moja statyczna strona hosta ma następujący obiekt JavaScriptObject:

var CurrentTheme = {
highlightColor: "#FFFFFF",
shadowColor: "#808080",
errorColor: "#FF0000",
errorIconSrc: "stopsign.gif"
};

oraz w moim module AbstractPresenterModule:

public class AppModule extends AbstractPresenterModule {

@Override
protected void configure() {

Dictionary xx = Dictionary.getDictionary("Properties");



}
}

Rodzi to następujący błąd:

15:49:15.657 [ERROR] [mobile] (Dictionary.java:-2) 2014-04-01 15:49:15,635 [FATAL] Uncaught Exception:
java.lang.ExceptionInInitializerError: null
at com.gwtplatform.mvp.client.ApplicationControllerImpl.init(ApplicationControllerImpl.java:9)
at test.mobile.client.Mobile.startApplication(Mobile.java:67)
at test.mobile.client.Mobile$1.execute(Mobile.java:32)
at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:345)
at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78)
at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:347)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Deferred binding failed for "com.gwtplatform.mvp.client.DesktopGinjector" (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.shared.GWT.create(GWT.java:72)
at com.google.gwt.core.client.GWT.create(GWT.java:86)
at com.gwtplatform.mvp.client.DesktopGinjectorProvider.get(DesktopGinjectorProvider.java:8)
at com.gwtplatform.mvp.client.ClientGinjector.<clinit>(ClientGinjector.java:11)
at com.gwtplatform.mvp.client.ApplicationControllerImpl.init(ApplicationControllerImpl.java:9)
at test.mobile.client.Mobile.startApplication(Mobile.java:67)
at test.mobile.client.Mobile$1.execute(Mobile.java:32)
at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:345)
at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78)
at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:347)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.UnsatisfiedLinkError: com.google.gwt.i18n.client.Dictionary.attach(Ljava/lang/String;)V
at com.google.gwt.i18n.client.Dictionary.attach(Native Method)
at com.google.gwt.i18n.client.Dictionary.<init>(Dictionary.java:120)
at com.google.gwt.i18n.client.Dictionary.getDictionary(Dictionary.java:93)
at test.mobile.client.gin.WebAppModule.configure(WebAppModule.java:25)
at com.google.gwt.inject.client.AbstractGinModule.configure(AbstractGinModule.java:46)
at com.google.gwt.inject.rebind.adapter.GinModuleAdapter.configure(GinModuleAdapter.java:57)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at com.google.gwt.inject.rebind.BindingsProcessor.createBindingsForModules(BindingsProcessor.java:201)
at com.google.gwt.inject.rebind.BindingsProcessor.process(BindingsProcessor.java:102)
at com.google.gwt.inject.rebind.GinjectorGeneratorImpl.generate(GinjectorGeneratorImpl.java:79)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:74)
at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:676)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)

Jak mogę uzyskać dostęp do JavaScriptObject z mojej klasy Module?

Odpowiedzi:

1 dla odpowiedzi № 1

Z dokumentów Gina https://code.google.com/p/google-gin/wiki/GinFaq:

Ponieważ twoja klasa Module jest faktycznie wykonywana w czasie kompilacji, musisz upewnić się, że jej metoda configure (...) nie wykonuje bezpośrednio kodu po stronie klienta GWT.

Dlatego nie możesz używać Dictionary w środku configure metoda twojego AbstractPresenterModule.