GWT popuPanel.hide()不起作用

时间:2017-08-14 14:43:02

标签: gwt

我的观点很简单。有uiBinder和类自己:

public class NewNotePopupPanel extends Composite implements NewNoteView {
interface NewNotePopupPanelUiBinder extends UiBinder<PopupPanel, NewNotePopupPanel> {
}

private static NewNotePopupPanelUiBinder ourUiBinder = GWT.create(NewNotePopupPanelUiBinder.class);


@UiField
PopupPanel popupPanel;
@UiField
VerticalPanel newNoteMainPanel;
@UiField
HorizontalPanel newNoteHeader;
@UiField
Label storedNoteTitle;
@UiField
DateLabel noteCreatedDate;
@UiField
VerticalPanel contentPanel;
@UiField
TextBox currentNoteTitle;
@UiField
RichTextArea contentTextArea;
@UiField
HorizontalPanel newNoteFooter;
@UiField
CheckBox favorite;
@UiField
Button save;
@UiField
Button close;

private Presenter presenter;

static {
    Resources.INSTANCE.style().ensureInjected();
}

public NewNotePopupPanel() {
    initWidget(ourUiBinder.createAndBindUi(this));
}

@UiHandler("favorite")
void onFavoriteCheckBoxClicked(ClickEvent event) {
    if (presenter != null) {
        presenter.onFavoriteCheckBoxClicked();
    }
}

@UiHandler("save")
void onApplyButtonClicked(ClickEvent event) {
    if (presenter != null) {
        presenter.onApplyButtonClicked();
    }
}

@UiHandler("close")
void onCancelButtonClicked(ClickEvent event) {
    popupPanel.hide();
}
}

UiBinder的:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
         xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field="res" type="ru.beleychev.notes.client.ui.Resources"/>
<g:PopupPanel ui:field="popupPanel" width="600px" modal="true" title="Edit Note" addStyleNames="{res.style.mainPanel}">
    <g:VerticalPanel ui:field="newNoteMainPanel">
        <g:HorizontalPanel ui:field="newNoteHeader">
            <g:Label ui:field="storedNoteTitle" addStyleNames="{res.style.label}"/>
            <g:DateLabel ui:field="noteCreatedDate" customFormat="EEE, MMM d, yyyy"
                         addStyleNames="{res.style.label}"/>
        </g:HorizontalPanel>
        <g:VerticalPanel ui:field="contentPanel">
            <g:TextBox ui:field="currentNoteTitle" addStyleNames="{res.style.searchBox}"/>
            <g:RichTextArea ui:field="contentTextArea" focus="true"/>
        </g:VerticalPanel>
        <g:HorizontalPanel ui:field="newNoteFooter">
            <g:CheckBox ui:field="favorite"/>
            <g:Button ui:field="save" text="Save" addStyleNames="{res.style.button}"/>
            <g:Button ui:field="close" text="Close" addStyleNames="{res.style.button}"/>
        </g:HorizontalPanel>
    </g:VerticalPanel>
</g:PopupPanel>

此弹出窗口从另一个视图打开。一切都好。 我没有接口问题。但不幸的是,&#34;关闭&#34;按钮不会关闭弹出窗口。它很简单(易于使用)。问题是什么? )期待你的建议,伙计们。提前谢谢。

1 个答案:

答案 0 :(得分:4)

来自why can't i hide DialogBox in UiBinder in GWT?

在谈到将它们添加到DOM时,

DialogBox(和PopupPanels一般)不像任何其他小部件那样工作。您不应该像以前那样直接将它们附加到它(即panel.add(yourDialogBox)UiBinder XML文件中)。相反,您应该创建它们,并简单地调用hide()/show()等方法来显示/隐藏它(即,在DOM的末尾附加/分离)