1

Not unique in window modal

asked 2014-06-03 21:24:09 +0800

wigberto gravatar image wigberto
52 4

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

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2014-06-04 09:06:51 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

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

link publish delete flag offensive edit

Comments

Thank you. it has worked correctly with @Wire("window").

wigberto ( 2014-06-04 09:15:19 +0800 )edit
1

answered 2014-06-04 08:58:36 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-06-04 09:00:26 +0800

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

link publish delete flag offensive edit

Comments

Thank you. it has worked correctly.

wigberto ( 2014-06-04 09:14:55 +0800 )edit
0

answered 2014-06-03 21:34:50 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

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

link publish delete flag offensive edit
0

answered 2014-06-04 08:14:15 +0800

wigberto gravatar image wigberto
52 4

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>
link publish delete flag offensive edit
0

answered 2014-06-04 15:09:34 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2014-06-04 15:09:49 +0800

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-06-03 21:24:09 +0800

Seen: 39 times

Last updated: Jun 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More