-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm sorry for my English. I have a modal window created to show messages of error and when I execute it more than once it gives me the following error. window.detach () does not it finish the modal window?
Not unique in ID space [Page bI1Q7]: errorMessageBoxWindow
@Command
public void closeWindowModal() {
win.detach();
}
<hlayout style="text-align:right">
<button label="Cerrar"
onClick="@command('closeWindowModal')" width="125px" height="60px" />
</hlayout>
Than you
I have made a quick sample with your code and it works fine (both in ZK 6.5 and ZK 7). I suspect that the error is related to the way you create this window.
I am using the following @command to create your modal window:
@Command
public void openErrorsWindow() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("errorXml", new ErrorXml());
Executions.createComponents("/error-message-box.zul", winMain, params);
}
where "winMain" is the current window component which should be the parent of your modal window.
Do you pass the right "parent" window to the modal dialog?
Hope that helps
Costas
In your case you need not an 'ID' for the window because you have only ONE in the zul that you will wire in the VM. So let ZK generate the ID for it.
zul:
<zk>
<window border="normal"
apply="org.zkoss.bind.BindComposer" width="460px" height="215px"
viewModel="@id('vm') init('com.fcclogistica.carrusel.manager.ErrorMessageBoxManager')"
position="center,center" mode="modal"
...
VM.java
@Wire("window")
private Window win;
...
@Command
public void closeWindowModal() {
win.onClose();
}
best Stephan
Yes. Detach() should remove the dialog from the DOM. Please post a complete sample. I guess there is a bug somewhere in your code.
Costas
My code is:
public class ErrorMessageBoxManager {
private ErrorXml errorXml = new ErrorXml();
@Wire("#errorMessageBoxWindow")
private Window win;
public ErrorXml getErrorXml() {
return errorXml;
}
public void setErrorXml(ErrorXml errorXml) {
this.errorXml = errorXml;
}
@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view,
@ExecutionArgParam("errorXml") ErrorXml errorXml) {
Selectors.wireComponents(view, this, false);
this.errorXml = errorXml;
}
@Command
public void closeWindowModal() {
win.detach();
}
}
<zk>
<window id="errorMessageBoxWindow" border="normal"
apply="org.zkoss.bind.BindComposer" width="460px" height="215px"
viewModel="@id('vm') @init('com.fcclogistica.carrusel.manager.ErrorMessageBoxManager')"
position="center,center" mode="modal"
action="show: slideDown;hide: slideUp" closable="true"
onCancel="@command('closeWindowModal')">
<caption label="${labels.viewModal.titleError}"
style="color: #000080; font-weight: bold" />
<separator height="10px"></separator>
<hlayout style="text-align:center">
<div children="@load(vm.errorXml.erroresList)">
<template name="children">
<label value="${each.error}"
style="color:#fb2900; font-weight:bold; font-size: 24px; text-align:center" />
</template>
</div>
</hlayout>
<separator height="10px"></separator>
<hlayout style="text-align:center">
<div children="@load(vm.errorXml.erroresList)">
<template name="children">
<label value="${each.description}"
style="color:#fb2900; font-weight:bold; font-size: 24 px; text-align:center" />
</template>
</div>
</hlayout>
<separator height="30px"></separator>
<hlayout style="text-align:right">
<button label="Cerrar"
onClick="@command('closeWindowModal')" width="125px" height="60px" />
</hlayout>
</window>
</zk>
As the solution of Terry is good, I prefer not to mix MVVM with MVC.
You have 2 different solutions that you can do in MVVM :
First one : You only need to detach => directly in the zul
<button label="Cerrar" onClick="spaceOwner.detach()" width="125px" height="60px" />
Second one from your Viewmodel, the zul stay's the same :
@Command
public void closeWindowModal(@ContextParam(ContextType.SPACE_OWNER) final Window win) {
win.detach();
}
Greetz chill.
Asked: 2014-06-03 21:24:09 +0800
Seen: 39 times
Last updated: Jun 04 '14
ArrayIndexOuOfBoundsException showing Messagebox
error PWC2788: setAttribute: Non-serializable attribute with name javax.zkoss.zk.ui.Session
no grammar constraints (dtd or xml schema) detected for the document
ListModelList.clear() - Error in ZK Framework?
Getting wierd NullPointerException when using Shiro
Script error when doing stuff in background thread