【问题标题】:Error while trying to use gwt-cal and gwt-dnd尝试使用 gwt-cal 和 gwt-dnd 时出错
【发布时间】:2012-08-21 00:57:43
【问题描述】:

我有一个简单的 GWT 项目,我尝试使用 gwt-cal 小部件,但是当我尝试加载使用该小部件的页面时出现错误。

我按照指令here 使用gwt-cal 小部件,但它不起作用。我有 gwt-cal 的 0.9.3 版本,gwt-dnd 的 3.1.2 版本,我正在使用 GWT 2.4。

这是我使用 gwt-cal 小部件的页面:

public class ClientCalendarPage extends Composite {

private VerticalPanel mainPanel = new VerticalPanel();
private Calendar calendar;

public ClientCalendarPage() {
    CalendarSettings settings = new CalendarSettings();
    settings.setEnableDragDropCreation(false);
    settings.setEnableDragDrop(false);

    calendar = new Calendar();
    calendar.setSettings(settings);
    calendar.setDate(new Date()); // calendar date, not required
    calendar.setDays(3); // number of days displayed at a time, not required
    calendar.setWidth("500px");
    calendar.setHeight("400px");

    Appointment appt = new Appointment();
    appt.setStart(new Date(System.currentTimeMillis() + 86400000));
    appt.setEnd(new Date(System.currentTimeMillis() + 90000000));
    appt.setTitle("Test");
    appt.setStyle(AppointmentStyle.BLUE);
    calendar.addAppointment(appt);

    mainPanel.add(calendar);

    initWidget(mainPanel);
}
 }

这是我的 app.gwt.xml :

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='minoscrossfit'>
 <inherits name='com.google.gwt.user.User'/>
 <inherits name='com.google.gwt.user.theme.clean.Clean'/>                                   
 <inherits name='com.bradrydzewski.gwt.calendar.Calendar' />
 <inherits name='com.bradrydzewski.gwt.calendar.theme.google.Google' />
 <inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
 <entry-point class='com.afrsoftware.minoscrossfit.client.MinosCrossfit'/>
 <source path='client'/>
 <source path='shared'/>
</module>

最后,这是我得到的堆栈跟踪:

20:38:43.735 [ERROR] [minoscrossfit] Error while executing the JavaScript provider for property 'locale'

com.google.gwt.core.client.JavaScriptException: (TypeError): Property 'locale' of object  is not a function
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.computePropertyValue(ModuleSpacePropertyOracle.java:193)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.getSelectionProperty(ModuleSpacePropertyOracle.java:130)
at com.google.gwt.resources.ext.ResourceGeneratorUtil.getLocale(ResourceGeneratorUtil.java:543)
at com.google.gwt.resources.ext.ResourceGeneratorUtil.findResources(ResourceGeneratorUtil.java:435)
at com.google.gwt.resources.ext.ResourceGeneratorUtil.findResources(ResourceGeneratorUtil.java:290)
at com.google.gwt.resources.ext.ResourceGeneratorUtil.findResources(ResourceGeneratorUtil.java:254)
at com.google.gwt.resources.rg.CssResourceGenerator.getResources(CssResourceGenerator.java:564)
at com.google.gwt.resources.rg.CssResourceGenerator.prepare(CssResourceGenerator.java:506)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.initAndPrepare(AbstractClientBundleGenerator.java:1043)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.initAndPrepare(AbstractClientBundleGenerator.java:1069)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.generateIncrementally(AbstractClientBundleGenerator.java:412)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.allen_sauer.gwt.dnd.client.util.DragClientBundle.&lt;clinit&gt;(DragClientBundle.java:72)
at com.allen_sauer.gwt.dnd.client.util.DragEntryPoint.onModuleLoad(DragEntryPoint.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)

谁能看出我做错了什么?

【问题讨论】:

  • 您在开发模式下使用什么 Web 浏览器?您确定您拥有正确版本的 GWT 浏览器插件吗?
  • 我正在使用 Chrome 浏览器并且插件是最新的。今天早上我在 Firefox 上试用了我的应用程序,它工作正常。之后,我尝试在另一台计算机上检查我的项目以确保它正常工作,但它不是(在任何具有最新插件的浏览器上)

标签: gwt


【解决方案1】:

我发现了问题。我的项目中缺少一些语言环境。我改变了我的 app.gwt.xml 并且它起作用了。我使用文档here 来解决这个问题。

这是我的 app.gwt.xml 现在的样子:

<?xml version="1.0" encoding="UTF-8"?>
 <module rename-to='minoscrossfit'>
  <inherits name='com.google.gwt.user.User'/>
  <inherits name="com.google.gwt.i18n.I18N"/>
  <extend-property name="locale" values="fr"/>
  <extend-property name="locale" values="fr_CA"/>
  <extend-property name="locale" values="en"/>
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>                                     
  <inherits name='com.bradrydzewski.gwt.calendar.Calendar' />
  <inherits name='com.bradrydzewski.gwt.calendar.theme.google.Google' />
  <inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
  <entry-point class='com.afrsoftware.minoscrossfit.client.MinosCrossfit'/>
  <source path='client'/>
  <source path='shared'/>
 </module>

一个小项目->在 Eclipse 中清理似乎有助于解决我的问题。

我在更改 app.gwt.xml 后添加了一个类似的问题,这是因为我团队中的某个人(可能是我)提交了一个不应该提交的文件(nocache.js),所以使用了新的 jar项目中不在此文件中。更改 app.gwt.xml 会引发应用程序的重新编译,并生成一个新的 nocache.js 文件(包含 jar 中所有需要的函数)。

【讨论】:

  • 我遇到了同样的问题,但是我无法使用参考链接上的方向来修复它。在我的代码中,我使用 param.toLowerCase(Locale.ENGLISH) 其中 param 是一个字符串。我虽然它应该根据this 工作。有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-15
  • 1970-01-01
  • 1970-01-01
  • 2012-03-11
相关资源
最近更新 更多