You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2012/01/11 00:23:03 UTC

Event propagation

I have a component Header and in there I have a menu. What I want is that on
the click in that menu I refresh two ajax zones one in the header (the ajax
zone in which is the menu) and the other which is in the main page. How can
I best propagate the event, or should I use another way like injecting zone
in the header component?

The major problem is that I need first that the method from the Header
component (this method sets what is clicked in the menu) activate first and
then the one in the main page (it fills the main page with data based on the
selected category from the menu)

Any ideas what should be the best thing? Any help would be appreciate 

Cheers

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Event-propagation-tp5135568p5135568.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Event propagation

Posted by bhorvat <ho...@gmail.com>.
Hi,

Thank you for fast response and sorry for slow on my side (been busy
lately).

I have implemented AjaxResponseRenderer  and it worked perfectly. 

I agree that it may not be the best design that component change something
on the outside, which is why this approach works great. I would just catch
the same event in the both header and main page and using
AjaxResponseRenderer I would refresh both pages.

As for the layout. What I was trying to do is to put menu in the header and
since on menu selection I need to change the main page I needed to implement
something like this. 

BTW is it possible to somehow change the order of the component responding.
It always load main page and then the component Header. So say for example
when javascript is loading from the main page

    @Inject
    @Path("context:scripts/models.js")
    private org.apache.tapestry5.Asset jsModels;

    @Environmental
    private JavaScriptSupport rendering;

    @SetupRender
    void importJavaScript() {
        rendering.importJavaScriptLibrary(jsModels);
    }

it will render that before the stuff form the header(which contains scripts
for needed for every page). Should I be using different way to render js? It
would be good if say I wanted to override the function for specific page so
I put that function in the fail for that page and since it renders after the
function from the header it will override it

Cheers and thansk

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Event-propagation-tp5135568p5147596.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Event propagation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 10 Jan 2012 21:23:03 -0200, bhorvat <ho...@gmail.com>  
wrote:

> I have a component Header and in there I have a menu. What I want is  
> that on the click in that menu I refresh two ajax zones one in the  
> header (the ajax zone in which is the menu) and the other which is in  
> the main page. How can I best propagate the event, or should I use  
> another way like injecting zone in the header component?

Having a component change things outside it is not a good idea in  
principle. Try to avoid this kind of situation.

I'd try adding a parameter to both Header and Menu which would receive  
which external zone to update and make the page use it.

> The major problem is that I need first that the method from the Header
> component (this method sets what is clicked in the menu) activate first  
> and then the one in the main page (it fills the main page with data  
> based on the selected category from the menu)

Handle the event in Header and, inside the handler method, trigger an  
event with the same name using ComponentResources.triggerEvent().

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Event propagation

Posted by Taha Hafeez Siddiqi <ta...@gmail.com>.
Hi

Use AjaxResponseRenderer 

http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/ajax/AjaxResponseRenderer.html

http://tawus.wordpress.com/2011/10/01/tapestry-5-3-new-features-part-2/

regards
Taha

On Jan 11, 2012, at 4:53 AM, bhorvat wrote:

> I have a component Header and in there I have a menu. What I want is that on
> the click in that menu I refresh two ajax zones one in the header (the ajax
> zone in which is the menu) and the other which is in the main page. How can
> I best propagate the event, or should I use another way like injecting zone
> in the header component?
> 
> The major problem is that I need first that the method from the Header
> component (this method sets what is clicked in the menu) activate first and
> then the one in the main page (it fills the main page with data based on the
> selected category from the menu)
> 
> Any ideas what should be the best thing? Any help would be appreciate 
> 
> Cheers
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Event-propagation-tp5135568p5135568.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>