我是GXT的新手(以及GWT/GWTP)。我想知道当显示包含其面板的模态对话框时,我是否可以懒洋洋地加载gxt(4.0)[自定义]小部件(对话框最初未显示,只有在单击按钮时才会出现)。
>我想要这种行为的原因是,此窗口小部件需要加载一个小程序HTML代码,当页面最初实例化所有其他字段窗口小部件/面板/对话框时,该代码无法使用。因此,我需要延迟从另一个应用程序获得小程序代码,直到明确显示对话框为止。
这是可能的吗?
lazy lazy lazy loage of图像和URL加载到GWT框架中(iframeElement)。一旦使用LoadHandler事件加载了图像/URL,就可以捕获事件。
private void loadLoginPage() {
final Frame frame = new Frame(url_base + url_login); // set the frames url
frame.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
// Get the document from the loaded frame (similar to RootPanel on main page)
Document doc = IFrameElement.as(frame.getElement()).getContentDocument();
// From here you can wrap widgets in the frame like this
final TextBox username = TextBox.wrap(doc.getElementById("username")); // from the html doc using id="username"
// grab a div element
DivElement div = DivElement.as(doc.getElementById("mydiv"));
// Create content to be added to the doc
ButtonElement button_elem = doc.createPushButtonElement();
Button button = Button.wrap(button_elem);
// attach to the document
div.appendChild(button.getElement());
}
});
// Attach to DOM
RootPanel.get("mything").add(frame);
}
,对于图像加载类似。
Image image = new Image(image_url);
image.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
// image is ready to be used.
}
});
// attach to DOM to initiate loading of the image
希望这会有所帮助...