-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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!
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();
}
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();
}
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 )editAsked: 2014-01-27 07:59:54 +0800
Seen: 62 times
Last updated: Jan 28 '14
composite component help [closed]
EL in a forEach @command not working?
Different template for each grid row
Cardlayout animation is broken
Grid RowRender slow using 6.5.1 and sizable=true
setVisible(false), component will load or not
Decimalbox and doublebox value rounded on iPad
history management with page status