1

Problem with closing generated popup window

asked 2014-01-27 07:59:54 +0800

demizon gravatar image demizon
179 1 6

updated 2014-01-27 10:54:34 +0800

Hi guys, I am getting java.lang.NullPointerException when trying to call detach() method on my popup window, generated from my main app window.

part of my main modelview file(method which generates popup):

@Command
@NotifyChange({"modulsList"})
public void copyModul(@BindingParam("modul") Moduls myModul) {
            showModal(myModul);
            modulsList=modulsManager.getAll();
        }
public void showModal(Moduls myModul) {
            Map<String, Moduls> arguments = new HashMap<String, Moduls>();
            arguments.put("myModul", myModul);
            Window window = (Window) Executions.createComponents(
                    "modulsEditor/copyModul.zul",null ,arguments);
            window.doModal();
        }

relevant part of popup modelview file:

@Wire
Window modalDialog;

@Command
public void submit() {
        modalDialog.detach();//this method generates null pointer exception
        }

copyModul.zul:

<window id="modalDialog" title="New modul" border="normal" width="460px"
     apply="org.zkoss.bind.BindComposer" viewModel="@id('tvm') @init('com.leoni.viewModel.PopupViewModel')"
    position="center,center" closable="true"
    action="show: slideDown;hide: slideUp">
    <vlayout>
         <grid>
           ...
         </grid>
        <button  label="Create" onClick="@command('submit')"/>
    </vlayout>
</window>

Thank you in advance for your help!

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2014-01-27 09:58:44 +0800

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

updated 2014-01-28 11:39:08 +0800

Oke, it doesn't work cause you are using MVVM and @Wire is normally disabled.

I give you 2 solutions :

<button label="Close" onClick="spaceOwner.detach()" />

or in zul :

<button label="Close" onClick="@command('close')" />

with in the vm :

@Command
public void close(@ContextParam(ContextType.SPACE_OWNER) final Window spaceOwner) {
    // what you want to do before close
    spaceOwner.detach();

}
link publish delete flag offensive edit

Comments

i have updated my post

demizon ( 2014-01-27 10:55:03 +0800 )edit

I used 2nd solution, works perfectly, thank you!

demizon ( 2014-01-27 11:47:51 +0800 )edit

@demizon your welcome

chillworld ( 2014-01-27 12:08:07 +0800 )edit
1

answered 2014-01-28 12:24:14 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Good explanation by Chillworld Let me give you a more specific solution by changing little bit code

@Command
public void doDeleteFee(@ContextParam(ContextType.VIEW) Component view) {
//Some Business Logic
view.detach();
}
link publish delete flag offensive edit

Comments

Also correct. For those who want to know what ContextType there are and for what they stand : http://www.zkoss.org/javadoc/latest/zk/org/zkoss/bind/annotation/ContextType.html

chillworld ( 2014-01-28 14:13:09 +0800 )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-01-27 07:59:54 +0800

Seen: 62 times

Last updated: Jan 28 '14

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