0

How to remove a component created with Executions.createComponents

asked 2012-04-05 02:02:02 +0800

xerxes gravatar image xerxes
30

In the controller class I'm adding a new component to the mainWindow like that:

Executions.createComponents("/includes/menu.zul", mainWindow, null);

And menu.zul is added to the bottom of my window exactly like I want.

Now the problem: I want one of the methods in the same controller class to be able to detach or remove menu.zul component. I can't call detach() method directly because I don't know that object's name or ID. Any ideas please?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-04-05 02:25:14 +0800

gyowanny gravatar image gyowanny
283 1 2 6

updated 2012-04-05 02:25:43 +0800

Can you keep a reference to the menu object in your composer? Like a class field?

public class MyComposer extends GenericForwardComposer{

     Component menu;

     public void doAfterCompose(Component comp){
          this.menu = Executions.createComponents("/includes/menu.zul", mainWindow, null);
     }

     private void removeMenu(){
         if (this.menu != null){
              menu.detach();
              mainWindow.invalidate(); //force mainWindow to readraw
         }
     }
}
/code]

link publish delete flag offensive edit

answered 2012-04-05 03:07:37 +0800

xerxes gravatar image xerxes
30

Spot on gyowanny, thank you!

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: 2012-04-05 02:02:02 +0800

Seen: 157 times

Last updated: Apr 05 '12

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