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 2011/09/23 14:54:35 UTC

Handling components event in the page that includes the component

Is it possible to handle the components event in the page that includes the
component.

Say I have a component and in that component I have two submit links with
their own id's. How do I see which link was clicked in the page that
includes the component?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833388.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: Handling components event in the page that includes the component

Posted by bhorvat <ho...@gmail.com>.
Ok let try explaining everything from the top :D

I have a page called Index and in that page I have included a component
called Popup. Now this component is basically a html popup with two tapestry
links. Then I surround this component in a form and when I click the link
(the link is from the component) it submits a form. The form is then handled
in the page Index and everything is great. 

What I now need is a way to tell those two links apart.Now if I put in the
page Index method

void onSelected(){

}

it is triggered for both links. What I want is to separate and to create
this method for both links. Something like

void onSelectedFromFirstLinkID(){

}

void onSelectedFromSecondLinkID(){

}

However this doesn't work. I thing that problem is that I need like the full
ID of the link. If I just use the id of the link the method is not
triggered, if I put those two methods in the component Popup then that those
methods are called. However I need those methods to be outside of component
Popup and inside page Index (so that every page can have different behaviour
for those links)

I have also tried 

@OnEvent(value=EventConstants.SELECTED, component="popup.firstLinkId")
void test(){
}

@OnEvent(value=EventConstants.SELECTED, component="popup/firstLinkId")
void test(){
}

@OnEvent(value=EventConstants.SELECTED, component="firstLinkId")
void test(){
}

but non work. So what I need is to know what is the full name of the element
inside a component that is included in a page?

I hope I have explained it better :D












--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833808.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: Handling components event in the page that includes the component

Posted by Chris Poulsen <ma...@nesluop.dk>.
Hi,

I'm still not clear on what you are doing and where - did your mail client
strip out your source code example? ;)

http://tapestry.apache.org/component-events.html should explain how the
handler stuff works.

-- 
Chris

On Fri, Sep 23, 2011 at 3:53 PM, bhorvat <ho...@gmail.com> wrote:

> Yea I come to the same conclusion by trying to insert a method
>
> void onSelected{
> }
>
> This method is activated, but I need to activate it with a ID so that I can
> have two methods
>
> void onSelectedFromFirst{
> }
>
> void onSelectedFromSecond{
> }
>
> However this doesn't work. So any ideas how should I call the ID of the
> element inside a component included in the page?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833597.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: Handling components event in the page that includes the component

Posted by bhorvat <ho...@gmail.com>.
Yea I come to the same conclusion by trying to insert a method 

void onSelected{
}

This method is activated, but I need to activate it with a ID so that I can
have two methods

void onSelectedFromFirst{
}

void onSelectedFromSecond{
}

However this doesn't work. So any ideas how should I call the ID of the
element inside a component included in the page?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833597.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: Handling components event in the page that includes the component

Posted by Chris Poulsen <ma...@nesluop.dk>.
Events bubble up in the page hierarchy afaik. So you could try to postfix
your handlers with "From<my-t:id>"

something like: onActionFromMyComponentId(...) ?

-- 
Chris

On Fri, Sep 23, 2011 at 3:24 PM, bhorvat <ho...@gmail.com> wrote:

> I probably din't explain it very well.
>
> I have component with two submit links in it. I also have a page that
> includes that component those two links. I need to write in that page that
> includes the components the event handling for those two links but I am not
> sure how. If I write handler in the Component.java it is handled but if I
> write it in the Page.java class it is not handled. Is there a way to push
> the event from the component up to the page?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833462.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: Handling components event in the page that includes the component

Posted by bhorvat <ho...@gmail.com>.
I probably din't explain it very well.

I have component with two submit links in it. I also have a page that
includes that component those two links. I need to write in that page that
includes the components the event handling for those two links but I am not
sure how. If I write handler in the Component.java it is handled but if I
write it in the Page.java class it is not handled. Is there a way to push
the event from the component up to the page?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4833462.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: Handling components event in the page that includes the component

Posted by Chris Poulsen <ma...@nesluop.dk>.
Nice to know you got it working!

I'm still interested in the docs mentioning the custom component events. If
they are missing, it should definitely be added. (I was expecting to find it
on http://tapestry.apache.org/component-events.html)

-- 
Chris

On Fri, Sep 23, 2011 at 6:02 PM, bhorvat <ho...@gmail.com> wrote:

> Yap, that solved all my problems.
>
> Thank you both so much
>
> Cheers
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4834135.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: Handling components event in the page that includes the component

Posted by bhorvat <ho...@gmail.com>.
Yap, that solved all my problems.

Thank you both so much

Cheers

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4834135.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: Handling components event in the page that includes the component

Posted by Chris Poulsen <ma...@nesluop.dk>.
Inject ComponentResources and poke around?

-- 
Chris

On Fri, Sep 23, 2011 at 5:45 PM, bhorvat <ho...@gmail.com> wrote:

> Perfect. This works. Thank you so much for your assistance.
>
> So I can't access the link's id from the page since it is local to the
> component but I can trigger an event and handle that. Great. :D
>
> Can I ask for one more thing if it is not to much of a trouble.
>
> Is it possible and how do I access the component's id from the inside of a
> component?
>
> Index.tml
>
> <t:Popup id="popupForwardMessage" t:source="sectionsForwardMessage"/>
>
> Popup.java - this is my component
>
>    @Parameter(required = true, defaultPrefix = "literal")
>    @Property
>    private String id;
>
> I pass this id as a parameter. But is it possible to access the components
> id. To avoid something like this
>
> <t:Popup t:id="popupForwardMessage" id="popupForwardMessage"
> t:source="sectionsForwardMessage"/>
>
> So what I want is just to pass
>
> <t:Popup t:id="popupForwardMessage" t:source="sectionsForwardMessage"/>
>
> and then in class Popup.java I access it. But I can't do it like this
>
>  @Parameter(required = true, defaultPrefix = "literal")
>    @Property
>    private String id;
>
> So any ideas?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4834084.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: Handling components event in the page that includes the component

Posted by bhorvat <ho...@gmail.com>.
Perfect. This works. Thank you so much for your assistance. 

So I can't access the link's id from the page since it is local to the
component but I can trigger an event and handle that. Great. :D

Can I ask for one more thing if it is not to much of a trouble. 

Is it possible and how do I access the component's id from the inside of a
component?

Index.tml

<t:Popup id="popupForwardMessage" t:source="sectionsForwardMessage"/>

Popup.java - this is my component

    @Parameter(required = true, defaultPrefix = "literal")
    @Property
    private String id;

I pass this id as a parameter. But is it possible to access the components
id. To avoid something like this

<t:Popup t:id="popupForwardMessage" id="popupForwardMessage"
t:source="sectionsForwardMessage"/>

So what I want is just to pass

<t:Popup t:id="popupForwardMessage" t:source="sectionsForwardMessage"/>

and then in class Popup.java I access it. But I can't do it like this

 @Parameter(required = true, defaultPrefix = "literal")
    @Property
    private String id;

So any ideas?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Handling-components-event-in-the-page-that-includes-the-component-tp4833388p4834084.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