asked
2014-07-30 21:53:58 +0800
snaef999 6 ● 1 I am trying to create a macro component with Window as the root component.
clientSelector.zul:
<?xml version="1.0" encoding="UTF-8"?>
<window visible="true" width="120px" border="normal" mode="overlapped"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('clientSelectorVM') @init('com.snaef.zk.widget.ClientSelector')">
<textbox id="mytextbox" value="@bind(clientSelectorVM.textValue)" />
<button onClick="@global-command('clientSelectorSave',
returnValue=clientSelectorVM.textValue)" />
</window>
ClientSelectorVM.java
public class ClientSelectorVM extends HtmlMacroComponent {
private static final long serialVersionUID = 1L;
private String _textValue;
@Wire
Textbox mytextbox;
public String getTextValue() {
return _textValue;
}
public void setTextValue(String textValue) {
_textValue = textValue;
mytextbox.setValue(_textValue);
}
}
However, when I try to use the component I get null exception on the line
mytextbox.setValue(_textValue);
I tried several things including specifying the id name directly @Wire("@mytextbox") and even tried bypassing the annotation and using the getfellow() method to directly get the component but both still return a null pointer exception.
If I simply change my outer component to a Div for example it will work fine.
From the documentation I see that Window uses its own ID space and I suspect the problem relates to this somehow but I dont know how or why.
How do I access mytextbox
?