[英]GWT- custom widget error: Cannot read property 'hash' of undefined
I am quite new to GWT. 我对GWT非常陌生。 I would like to extend some standard widget to suit my needs.
我想扩展一些标准的小部件以适合我的需求。 I've created my first widget
HorizontalTabs
, which extend classes from GWT MaterialDesign( Here is demo and here are sources ) And I am getting an error: Cannot read property 'hash' of undefined
我创建了我的第一个小部件
HorizontalTabs
,它从GWT MaterialDesign扩展了类( 这是演示 , 这是源 ),我收到一个错误: Cannot read property 'hash' of undefined
Here is code of view: 这是视图代码:
public class HorizontalTabs extends Composite {
private static HorizontalTabsUiBinder uiBinder = GWT.create(HorizontalTabsUiBinder.class);
interface HorizontalTabsUiBinder extends UiBinder<Widget, HorizontalTabs> {
}
public HorizontalTabs() {
initWidget(uiBinder.createAndBindUi(this));
}
}
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:gwt.material.design.client.ui">
<m:MaterialRow>
<m:MaterialRow>
<m:MaterialColumn grid="s12">
<m:MaterialTab ui:field="tab" backgroundColor="blue" indicatorColor="yellow" waves="YELLOW">
</m:MaterialTab>
</m:MaterialColumn>
</m:MaterialRow>
<m:MaterialRow ui:field="tabContentRow">
</m:MaterialRow>
</m:MaterialRow>
</ui:UiBinder>
To use it am adding it to one of my view class as follow: 要使用它,请将其添加到我的视图类之一,如下所示:
public class FilesView extends ViewWithUiHandlers<FilesUiHandlers> implements FilesPresenter.MyView {
interface Binder extends UiBinder<Widget, FilesView> {}
private static FilesViewUiBinder uiBinder = GWT.create(FilesViewUiBinder.class);
interface FilesViewUiBinder extends UiBinder<Widget, FilesView> {}
@UiField
MaterialRow row;
public FilesView() {
initWidget(uiBinder.createAndBindUi(this));
row.add(new HorizontalTabs());
}
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:gwt.material.design.client.ui">
<g:HTMLPanel>
<h2>Your files</h2>
<m:MaterialRow>
<m:MaterialRow ui:field="row">
</m:MaterialRow>
</m:MaterialRow>
</g:HTMLPanel>
</ui:UiBinder>
Everythink compiles ok. Everythink编译正常。 But problems occur when I try to enter the view that contain this widget.
但是,当我尝试进入包含此小部件的视图时会出现问题。
Here is the stack trace: 这是堆栈跟踪:
SEVERE: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: (TypeError) : Cannot read property 'hash' of undefinedcom.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: (TypeError) : Cannot read property 'hash' of undefined
at Unknown.fillInStackTrace_0_g$(cms-0.js@3:8443)
at Unknown.Throwable_3_g$(cms-0.js@8:8398)
at Unknown.Exception_3_g$(cms-0.js@18:8541)
at Unknown.RuntimeException_3_g$(cms-0.js@18:8582)
at Unknown.UmbrellaException_3_g$(cms-0.js@25:36497)
at Unknown.UmbrellaException_5_g$(cms-0.js@26:36558)
at Unknown.AttachDetachException_1_g$(cms-0.js@26:55009)
at Unknown.tryCommand_1_g$(cms-0.js@11:55065)
at Unknown.doAttachChildren_1_g$(cms-0.js@3:54662)
at Unknown.onAttach_2_g$(cms-0.js@8:54494)
at Unknown.setParent_2_g$(cms-0.js@12:54590)
at Unknown.adopt_0_g$(cms-0.js@14:54649)
at Unknown.add_14_g$(cms-0.js@8:54707)
at Unknown.add_13_g$(cms-0.js@8:54700)
at Unknown.add_66_g$(cms-0.js@8:77215)
at Unknown.add_11_g$(cms-0.js@8:54637)
at Unknown.add_65_g$(cms-0.js@43:77211)
at Unknown.setPanelContent_0_g$(cms-0.js@54:114885)
at Unknown.setInSlot_7_g$(cms-0.js@25:107982)
at Unknown.setInSlot_1_g$(cms-0.js@25:73077)
at Unknown.setInSlot_0_g$(cms-0.js@8:73066)
at Unknown.execute_27_g$(cms-0.js@30:76290)
at Unknown.$executeScheduled_0_g$(cms-0.js@40:11660)
at Unknown.runScheduledTasks_0_g$(cms-0.js@9:11382)
at Unknown.flushPostEventPumpCommands_0_g$(cms-0.js@5:11474)
at Unknown.execute_5_g$(cms-0.js@22:11613)
at Unknown.execute_4_g$(cms-0.js@19:11350)
at Unknown.apply_0_g$(cms-0.js@28:10845)
at Unknown.entry0_0_g$(cms-0.js@16:10901)
at Unknown.anonymous(cms-0.js@14:10881)
at Unknown.callback_0_g$(cms-0.js@45:11401)
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught:
I assume this is silly problem, but I really can not find solution. 我认为这是一个愚蠢的问题,但我确实找不到解决方案。 Please help.
请帮忙。
Maybe there is the way to find reason, but for me it is very hard to debug GWT application when I need to find runtime exception. 也许有找到原因的方法,但是对我来说,当我需要找到运行时异常时,调试GWT应用程序非常困难。
It may be the case that I did not have any public getters and setters and constructors for widget models objects. 可能是这样的情况,我没有小部件模型对象的任何公共获取器,设置器和构造函数。 But now I am not sure.
但是现在我不确定。 It started to work.
它开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.