0

How to access components for a dynamically added Include component

asked 2014-08-21 10:52:04 +0800

AAdel gravatar image AAdel
3 1

Dear All

I am new to ZK.

I have a toolbar zul file that contains a definition for a toolbar, this toolbar is used in different windows, and I want to capture the events fired from this toolbar in each window controller. When I add an Include component for the window and call the setSrc() function with argument tollbar.zul, and then try to reach the childrens of the Include component, I get empty array

My code is like

public class MyComposer extends SelectorComposer<component> {

public void addToolbar(Window win){
    Include incl=new Include();
    incl.setId("myToolbar");
    incl.setSrc("toolbar.zul");
    incl.setParent(win);

    for (Component c : incl.getChildren())
    {
        // This code is never reached as the getChildren() always return empty list
    }
 }

}

Please, help

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-08-21 13:54:10 +0800

Ganeshkhakare gravatar image Ganeshkhakare
150 4
public void addToolbar(Window win){
Include incl=new Include();
incl.setId("myToolbar");
incl.setSrc("toolbar.zul");
incl.setParent(win);
incl.afterCompose();

for (Component c : incl.getChildren())
{
    // This code is never reached as the getChildren() always return empty list
}

}

This should solve your problem. But not sure if it is good to call after compose method by developer.

link publish delete flag offensive edit
0

answered 2014-08-24 07:48:32 +0800

AAdel gravatar image AAdel
3 1

Thank you very much, it's working. But I did not get what did you mean by

"But not sure if it is good to call after compose method by developer."

in your answer.

Thank you very much for your cooperation. Ahmed Adel

link publish delete flag offensive edit

Comments

prob the incl.afterCompose(); line. You can Always try to remove the line cause normally this should be called automaticly. Now maybe you should take a look at templating? because if you repeat this code for each zul, you could make it generic.

chillworld ( 2014-08-24 20:17:07 +0800 )edit
Your answer
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
1 follower

RSS

Stats

Asked: 2014-08-21 10:52:04 +0800

Seen: 23 times

Last updated: Aug 24 '14

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