English 中文(简体)
在播放器工程中使用窗口。 提醒()
原标题:using Window.alert() in a playn project

只是测试我试图使用 com.google.gwt.user.client. Window 软件包中的 com.google.gwt.user. client. Window 功能。 但是,当我尝试运行程序时, 我得到了这样的错误消息 :

"Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor. "

我真的不明白。在我的游戏项目中,只有客户方代码在使用。有什么问题?

问题回答

GWT. create () 目前在 gwt 树干中用纯 java 支持 GWT 。 我正将它用于一个播放项目 {尽管我有一个小小故障 : < a href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

如果您下载和构建了树干, 您可以通过注册分类验证器来规避 GWT. create () 问题 。 在此情况下, 窗口类有一个静态的 Window Impl 实例, 当 jvm 击中窗口类时会丢弃这个错误 。 如果您注册了 Window Impl 的分类验证器, 这将不会发生 。 不幸的是, 窗口. 提醒方法会直接进入本地 js, 这样它仍然会投放在你身上 。

如果您不知道如何/ 想要从树干中建立 gwt, 请给我发一封电子邮件, 我可以将罐子寄给你。 如果您仍然对. ward () 作为本地方法有问题, 请告诉我, 我会创建一个定制的树干结构, 将. ward () 推迟到 Window Impl 单顿, 这样您就可以让它做些有意义的事情, 比如弹出警告信息 ; - }

如果您感到冒险, 下载 gwt 树干, 进入窗口, 将静态警报方法复制为窗口Impl 的试例级方法, 将原始方法代表到窗口Impl, 然后在您的 java 代码中, 调用 ServerGwtBridge. register (WindowImpl. class, new Class Instratistator (...)), 并返回您想要在 java 和 roid 中执行的. alert () 。





相关问题
Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to create a development/debug and production setup

I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it s fun). It was quickly corrected but I know it may happen again. After digging on ...

GWT error at runtime: ....style_0 is null

My code works fine in IE 8, but on firefox 3.5, the javascript fails to load. I used firebug to figure out why, and the error I get is (GWT detailed mode) My suspicion is that some style is not ...

GWT s hosted mode not working

I ve been stumped for a while trying to figure out why my GWT demo app isn t working in hosted mode so I went back and downloaded the Google Web Toolkit again, unzipped it and simply went to the ...

How to disable Google Visualizations Tool Tips?

Does anyone know how to disable the tool-tip boxes that popup when a Google Visualizations chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, the "...

GWT 2 CssResource how to

I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and ...

热门标签