GWT popuPanel.hide() 不起作用

GWT popuPanel.hide() doesnt work

我的看法很简单。本身就有uiBinder和class:

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>

此弹出窗口 window 从另一个视图打开。一切都很好。 我的界面没有问题。但是,不幸的是,"Close" 按钮不会关闭弹出窗口。这很简单(简单易行)。问题是什么? ) 伙计们,期待您的建议。提前谢谢你。

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

DialogBox(和一般的 PopupPanels)在谈到将它们添加到 DOM 时不像任何其他小部件那样工作。你永远不应该像你那样将它们直接附加到它(即 panel.add(yourDialogBox)UiBinder XML 文件中)。相反,您应该创建它们,并简单地调用 hide()/show() 和类似的方法来获取它 displayed/hidden (即 attached/detached 在 of/from 和 DOM 末尾)