/ / Як отримати ключ / значення JavaScriptObject у AbstractPresenterModule в GWTP? - java, javascript, gwt, gwtp, gwt-платформа

Як отримати ключ / значення JavaScriptObject у AbstractPresenterModule в GWTP? - java, javascript, gwt, gwtp, gwt-платформа

Я використовую GWTP і хочу використовувати Словник у моєму AbstractPresenterModule. Моя статична хост-сторінка має такий JavaScriptObject:

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

і в моєму AbstractPresenterModule:

public class AppModule extends AbstractPresenterModule {

@Override
protected void configure() {

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



}
}

Це спричиняє таку помилку:

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)

Як я можу отримати доступ до JavaScriptObject зі свого класу Module?

Відповіді:

1 для відповіді № 1

З документації Джина https://code.google.com/p/google-gin/wiki/GinFaq:

Оскільки ваш клас Module фактично виконується під час компіляції, ви повинні переконатися, що його метод configure (...) не виконує безпосередньо жодного коду на стороні клієнта GWT.

Тому ви не можете використовувати Dictionary всередині configure метод вашого AbstractPresenterModule.