GWT popuPanel.hide() doesnt work

I have simple view. There are uiBinder and class themselves:

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>

This popup window opens from another view. And there is all ok. I have no problems with interface. But, unfortunately, "Close" button doesn't close popup. It's simple (easy-peasy). What is the problem? ) Looking forward to your suggestions, guys. Thank you in advance.

Upvotes: 0

Views: 321

Answers (1)

KilledByCHeese
KilledByCHeese

Reputation: 872

from why can't i hide DialogBox in UiBinder in GWT?

DialogBox (and PopupPanels in general) does not work like any other widget when speaking about adding them to the DOM. You should never attach them directly to it (i.e., panel.add(yourDialogBox) or inside a UiBinder XML file) as you did. Instead you should create them, and simply call hide()/show(), and the like methods, to get it displayed/hidden (i.e., attached/detached at the end of/from the DOM)

Upvotes: 4

Related Questions