Created
March 14, 2013 18:09
-
-
Save cancerberoSgx/5163720 to your computer and use it in GitHub Desktop.
a simple UIBinder widget contains an html element with an id. AFTER calling initWidget(uiBinder.createAndBindUi(this)); document.getElementById() will return null. Only in an attach event listener I can retrieve the element by id. In the example I instantiate the widget directly from the entry point using RootPanel.get().add(new MainPanel())
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sgx.raphael4gwt.raphy.test.app; | |
public class MainPanel extends Composite { | |
private static MainPanelUiBinder uiBinder = GWT.create(MainPanelUiBinder.class); | |
interface MainPanelUiBinder extends UiBinder<Widget, MainPanel> { | |
} | |
public MainPanel() { | |
initWidget(uiBinder.createAndBindUi(this)); | |
Window.alert(Document.get().getElementById("chart1")); //null | |
addAttachHandler(new AttachEvent.Handler() { | |
@Override | |
public void onAttachOrDetach(AttachEvent event) { | |
Window.alert(Document.get().getElementById("chart1")+""); //not null | |
} | |
}); | |
} | |
} | |
<!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"> | |
<g:HTMLPanel> | |
<div id="chart1"></div> | |
</g:HTMLPanel> | |
</ui:UiBinder> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment