Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1598

Can't capture events triggered from composite component inside controller

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Normal Normal
    • None
    • 6.0.2
    • General

      The methods described at http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/Event%20Handling/Event%20Forwarding do not work when I try to forward Events from composite component that implement IdSpace. I tried some possibilities described at http://forum.zkoss.org/question/77605/cant-capture-events-triggered-from-composite-inside-controller/ and at least I found some tricky way, but this should work more easily. It should be an easy way to forward the events with origin inside the composite component to the composite component itself, and handle the event in the controller of the page where the composite component is used.

      I noticed that
      this.getPage().getDesktop().getComponentByUuidIfAny("this.getId()"))
      returns null in the event handlers inside the component's class. However, with this workaround I can forward the event:

      @Listen("onSelect = #cb")
      public void onCh(Event evt){

      // Always null, why?
      System.out.println(
      this.getPage().getDesktop().getComponentByUuidIfAny("this.getId()"));

      // Workaround
      Component target = null;
      for (Component c : this.getPage().getDesktop().getComponents()){
      if (c.getId().equals(this.getId()))

      { target = c; }

      }
      if (target != null)
      Events.sendEvent(target, evt);
      }

            Unassigned Unassigned
            takach takach
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: