what is wrong in my java zkoss program
updated
<?page title="example"?>
&开发者_JAVA百科lt;window id="music" apply="com.main">
<combobox id="combo" autodrop="true" onChanging="music.suggest()"/>
</window>
java
public class main extends GenericComposer{
/**
*
*/
private static final long serialVersionUID = 1L;
Combobox combo;
public void suggest() {
combo.getFellow("combo");
combo.getItems().clear();
combo.appendItem("Ace");
combo.appendItem("Ajax");
combo.appendItem("Apple");
combo.appendItem("Best");
combo.appendItem("Blog");
}
}
it says null pointer exception y???
I modified your code, you can give it a try :)
ZUL
<?page title="example"?> <window id="music" apply="com.mainComposer"> <combobox id="combo" autodrop="true"/> </window>
Java
public class mainComposer extends GenericForwardComposer{
Combobox combo; //ZK Auto Wired , use combo directly
public void onChanging$combo() { // ZK Autoforward (Awesome !!)
suggest();
}
public void suggest() {
combo.getItems().clear();
combo.appendItem("Ace");
combo.appendItem("Ajax");
combo.appendItem("Apple");
combo.appendItem("Best");
combo.appendItem("Blog");
}
}
Composers should extend the GenericForwardComposer and not Window. Try that and the autowiring should work.
精彩评论