0

How to refer to a macro component?

asked 2009-05-21 19:31:33 +0800

fusion35 gravatar image fusion35
237 2 5
Hi : Like other components that do get auto-wired, is macro component different? In the onCreate$() method it shows as null.
public class MyWindow extends Window implements AfterCompose{
    private Listbox listbox;
    private MyComp myComp;  // macro component


    public void onCreate$myWindow() {
      String str = myComp.getId();  // myComp is null;
    }
}
Macro zul
<window id="myComp" use="MyComp">
	<textbox id="tbName" value="@{myObj.name}" width="300px"/>
</window>
public class MyComp extends Window {

    private MyObj myObj;


    public MyObj getMyobj() {
        return myObj;
    }

    public void setMyobj(MyObj myObj) {
        this.myObj = myObj;
    }

    public void onCreate$myComp() {
        myObj = new MyObj();
    }
}
regards Devinder
delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-05-22 04:38:41 +0800

robbiecheng gravatar image robbiecheng
1144 2
http://robbiecheng.sys-co...

you have to extends org.zkoss.zk.ui.util.GenericForwardComposer, and use apply to associate the composer with your UI component.
Please refer to this article.

/robbie

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2009-05-21 19:31:33 +0800

Seen: 197 times

Last updated: May 22 '09

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