That example was really helpfull, thanks Geoff.

My case was somewhat more trivial (just a line of js) and I'm using got5 
jquery. The containing parent injects a reference to the cart-like component 
and handles events from other sibling components by invoking doRefresh, which 
triggers the client side to onRefresh:


    public void doRefresh() {
        log.debug("doRefresh");
        ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
            @Override
            public void run(JavaScriptSupport javascriptSupport) {
                String url = 
componentResources.createEventLink("refresh").toURI();
                javascriptSupport.addScript(
                        String.format("$('#cartZone').tapestryZone('update', 
{url : '%s'});", url));
            }
        });
    }

    public Object onRefresh() {
        log.debug("onRefresh");
        setup(); // prepare for render
        return cartZone.getBody();
    }


This works like a charm although I feel I'm boilerplating with this code. Any 
suggestions for improvement welcome.

  ----- Original Message -----
  From: Geoff Callender
  To: Tapestry users
  Sent: Sunday, September 07, 2014 1:44 AM
  Subject: Re: component events bubbling down?


  Here's a working example that solves it in the same way that you were trying 
- with bubble up and call down...

  
http://jumpstart.doublenegative.com.au/jumpstart7/together/ajaxcomponentscrud/persons

  ...where Persons, which is the page, calls list.doChangeOfSelectedPerson() in 
response to several bubbled-up events.

  Geoff


  On 7 Sep 2014, at 9:31 am, Chris Poulsen <mailingl...@nesluop.dk> wrote:

  > Hi,
  >
  > I believe that https://issues.apache.org/jira/browse/TAP5-2383 is about
  > this case. There are several possible solutions mentioned in that issue/its
  > comments.
  >
  > --
  > Chris
  >
  >
  > On Sun, Sep 7, 2014 at 12:16 AM, John <j...@quivinco.com> wrote:
  >
  >> I have a situation where a child component (C) fires an event that causes
  >> the containing component(B) to refesh it's content. Another component (A)
  >> that contains B also contains compoenent D. D needs also to fire an event
  >> that causes B to refesh it's content. The event needs to go down the
  >> component hierarchy.
  >>
  >> I've tried to inject component B into A and directky invoke the event
  >> handler, but it throws exceptions. Is there a proper way to handle this,
  >> like pushing the event downwards?
  >>
  >> John
  >>
  >> ---
  >> This email is free from viruses and malware because avast! Antivirus
  >> protection is active.
  >> http://www.avast.com
  >>



---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

Reply via email to