Calling a grand-parent's method from grand-children in different ID space [closed]

asked 2020-09-02 04:16:42 +0800

bztom35 gravatar image bztom35
103 4

Is it possible to call a grand-parent's method from popup grand-children in different ID space?

For example: ParentComposer

    @Listen("onClick = #updateDisplay")
      public void RefreshParentContent() {
          //process content update here

@Listen("onClick = #displayTabPanelUI")
    public void loadTabPanelUI() {
     Window userPreferenceWinTab   = (Window)  
    Executions.createComponents("Resources/Tools/UserSharePreferenceTab.zul",null, args);
         userPreferenceWinTab.addEventListener("onRefresh", new 
                 EventListener<Event>() {
                public void onEvent(Event event) throws Exception {
                    //call button "updateDisplay" refresh data.
                    Events.sendEvent(new Event("onClick",  updateDisplay, null));


    Window applyWin =(Window)Executions.createComponents("Resources/Tools/ApplyShareRelease.zul", applyTabPanel, args);
           applyWin.addEventListener("onRefresh", new EventListener<Event>() {
                                public void onEvent(Event event) throws Exception {
                                      //this calls to parent of parent's method.
                                    **Events.sendEvent(new Event("onClick",  
                                      userShareReleaseWinTab ,null));**

                             //this close the current popup window      
                               Events.sendEvent(new Event("onClick",  closeWin, null));



   @Listen("onClick = #applyChanges")
    public void fillingData() {
     //process any data here
     //call to its  grand parent to refresh data  
     //************** Call parent method to refresh **********
     Events.postEvent("onRefresh", applyShareReleaseWin, null);
delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by cor3000
close date 2020-09-03 09:08:03


I am sorry I can't really follow the code, even after reading through your example code 3 times... can you provide a runnable example e.g. on https://zkfiddle.org/ then it will be easier to help, basically any event can be sent/posted to any component, provided you have a reference to that object.

cor3000 ( 2020-09-02 11:24:02 +0800 )edit

based on my previous comment your question might change into something like ... how to get a reference of a certain component on a page

cor3000 ( 2020-09-02 11:32:31 +0800 )edit

Here is a runnable demo mock up to the best I can without using the actual source code.https://zkfiddle.org/sample/25q6omc/37-Sample-Mock-for-the-question

bztom35 ( 2020-09-02 12:47:45 +0800 )edit

it is possible to give the root window an ID e.g. mainWin and then wire it where needed https://zkfiddle.org/sample/25q6omc/38-Sample-Mock-for-the-question However there are more ways achieving the same... e.g. using event queues, or plain java to call methods directly.

cor3000 ( 2020-09-02 14:24:16 +0800 )edit

btw your windows are not children of one another, they are rather all root components on the page. When calling Executions.createComponents you don't specify a parent in the second parameter. Instead you pass null which creates a component at root level, not a child of the current window.

cor3000 ( 2020-09-02 14:29:14 +0800 )edit

Question tools

1 follower



Asked: 2020-09-02 04:16:42 +0800

Seen: 4 times

Last updated: Sep 02 '20

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