0
我有简单的看法。有UiBinder的和阶级本身:GWT popuPanel.hide()不工作
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>
该弹出式窗口从另一个视图中打开。一切都好。 我没有接口问题。但不幸的是,“关闭”按钮不会关闭弹出窗口。这很简单(容易)。问题是什么? )期待你的建议,伙计们。先谢谢你。
我想你说得对,但...你可以使用uibinder创建弹出窗口,只要它是根元素(就像你做的那样),你不应该做的就是把它作为一个嵌套元素来创建,因为这最终会成为panel.add调用,这对于弹出面板是不正确的。 –