Ich bin ziemlich neu in GWT. Ich würde gerne ein Standard-Widget nach meinen Bedürfnissen erweitern. Ich habe mein erstes Widget erstellt HorizontalTabs
, die Klassen von GWT Material Design erweitern (Here is demo und here are sources) Und ich erhalte eine Fehlermeldung: Cannot read property 'hash' of undefined
GWT-benutzerdefinierte Widget-Fehler: Kann nicht lesen Eigenschaft 'Hash' von undefined
Hier 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>
Um es zu nutzen ist Hinzufügen es zu einer meiner Ansichtsklasse wie folgt:
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 kompiliert ok. Aber Probleme treten auf, wenn ich versuche, die Ansicht einzugeben, die dieses Widget enthält. Hier
ist der 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$([email protected]:8443)
at Unknown.Throwable_3_g$([email protected]:8398)
at Unknown.Exception_3_g$([email protected]:8541)
at Unknown.RuntimeException_3_g$([email protected]:8582)
at Unknown.UmbrellaException_3_g$([email protected]:36497)
at Unknown.UmbrellaException_5_g$([email protected]:36558)
at Unknown.AttachDetachException_1_g$([email protected]:55009)
at Unknown.tryCommand_1_g$([email protected]:55065)
at Unknown.doAttachChildren_1_g$([email protected]:54662)
at Unknown.onAttach_2_g$([email protected]:54494)
at Unknown.setParent_2_g$([email protected]:54590)
at Unknown.adopt_0_g$([email protected]:54649)
at Unknown.add_14_g$([email protected]:54707)
at Unknown.add_13_g$([email protected]:54700)
at Unknown.add_66_g$([email protected]:77215)
at Unknown.add_11_g$([email protected]:54637)
at Unknown.add_65_g$([email protected]:77211)
at Unknown.setPanelContent_0_g$([email protected]:114885)
at Unknown.setInSlot_7_g$([email protected]:107982)
at Unknown.setInSlot_1_g$([email protected]:73077)
at Unknown.setInSlot_0_g$([email protected]:73066)
at Unknown.execute_27_g$([email protected]:76290)
at Unknown.$executeScheduled_0_g$([email protected]:11660)
at Unknown.runScheduledTasks_0_g$([email protected]:11382)
at Unknown.flushPostEventPumpCommands_0_g$([email protected]:11474)
at Unknown.execute_5_g$([email protected]:11613)
at Unknown.execute_4_g$([email protected]:11350)
at Unknown.apply_0_g$([email protected]:10845)
at Unknown.entry0_0_g$([email protected]:10901)
at Unknown.anonymous([email protected]:10881)
at Unknown.callback_0_g$([email protected]:11401)
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught:
Ich nehme dieses dumme Problem ist, aber ich kann wirklich nicht Lösung finden. Bitte helfen Sie.
Vielleicht gibt es die Möglichkeit, den Grund zu finden, aber für mich ist es sehr schwierig, GWT-Anwendung zu debuggen, wenn ich Runtime-Ausnahme finden muss.
Beide Widgets funktionieren gut (ohne gwtp-Klassen), mir sieht nichts falsch. Versuchen Sie, Ihre Anwendung zu debuggen, um herauszufinden, welches Problem die Datei verursacht. – Ajax