简体   繁体   中英

what is wrong in my java zkoss program

updated

<?page title="example"?>
<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM