Re: Handling components event in the page that includes the component

2011-09-24 Thread Geoff Callender
In case it helps, here is an example of custom components triggering events 
with no callback:


http://jumpstart.doublenegative.com.au/jumpstart/examples/component/crud/persons

and with callback (returning the zone(s) to update):


http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/componentscrud/persons

http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/gracefulcomponentscrud/persons

Geoff


On 24/09/2011, at 3:03 AM, Chris Poulsen wrote:

> Yeah I think that part should be mentioned - its a really neat feature! I'll
> dig into it and see if I can get around to whipping up a suggestion for
> JIRA.
> 
> -- 
> Chris
> 
> On Fri, Sep 23, 2011 at 6:56 PM, Thiago H. de Paula Figueiredo <
> thiag...@gmail.com> wrote:
> 
>> On Fri, 23 Sep 2011 13:11:25 -0300, Chris Poulsen 
>> wrote:
>> 
>> 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
>>> )
>>> 
>> 
>> Yep, that page is missing the event triggering part. Could you file a JIRA
>> for that so the committers don't forget it? :)
>> 
>> Basically, @Inject ComponentResources and use the triggerEvent(String
>> eventType, Object[] contextValues, ComponentEventCallback callback) method.
>> You'll only need to implement a ComponentEventCallback if you want to get
>> the return value of the handler method. The return value of triggerEvent()
>> says if the event was handled or not. Very simple after you implement your
>> first one. :)
>> 
>> 
>> --
>> 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
Yeah I think that part should be mentioned - its a really neat feature! I'll
dig into it and see if I can get around to whipping up a suggestion for
JIRA.

-- 
Chris

On Fri, Sep 23, 2011 at 6:56 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Fri, 23 Sep 2011 13:11:25 -0300, Chris Poulsen 
> wrote:
>
>  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
>> )
>>
>
> Yep, that page is missing the event triggering part. Could you file a JIRA
> for that so the committers don't forget it? :)
>
> Basically, @Inject ComponentResources and use the triggerEvent(String
> eventType, Object[] contextValues, ComponentEventCallback callback) method.
> You'll only need to implement a ComponentEventCallback if you want to get
> the return value of the handler method. The return value of triggerEvent()
> says if the event was handled or not. Very simple after you implement your
> first one. :)
>
>
> --
> 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
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread Thiago H. de Paula Figueiredo
On Fri, 23 Sep 2011 13:11:25 -0300, Chris Poulsen   
wrote:



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)


Yep, that page is missing the event triggering part. Could you file a JIRA  
for that so the committers don't forget it? :)


Basically, @Inject ComponentResources and use the triggerEvent(String  
eventType, Object[] contextValues, ComponentEventCallback callback)  
method. You'll only need to implement a ComponentEventCallback if you want  
to get the return value of the handler method. The return value of  
triggerEvent() says if the event was handled or not. Very simple after you  
implement your first one. :)


--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
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  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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
Inject ComponentResources and poke around?

-- 
Chris

On Fri, Sep 23, 2011 at 5:45 PM, bhorvat  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
>
> 
>
> 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:source="sectionsForwardMessage"/>
>
> So what I want is just to pass
>
> 
>
> 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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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



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



So what I want is just to pass



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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
Wow Thiago, that is pretty cool. I haven't found (/noticed) this in the docs
yet, can you provide a pointer?

-- 
Chris

On Fri, Sep 23, 2011 at 5:27 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Fri, 23 Sep 2011 10:23:50 -0300, Boris Horvat 
> wrote:
>
>  I probably din't explain it very well.
>>
>
> I disagree. :) I guess I haven't explained my suggestion well.
>
>  I have component with two submit links in it. I also have a page that
>> includes 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.
>>
>
> This happens because you're specifying the component id in your event
> handler method, which is local to the component or page at which it was
> declared.
>
>
>  Is there a way to push the event from the component up to the page?
>>
>
> Non-render events in components are bubbled to the page unless someone
> handles them in between. Just use event name instead of component id in your
> handler method, as I've suggested before. ;)
>
> 
> 
>
> In your page:
>
> void onEvent1() { ... } or void @OnEvent("event1") anyName() { ... }
>
> void onEvent2() { ... } or void @OnEvent("event2") anyOtherName() { ... }
>
>
> --
> 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-h...@tapestry.apache.org
>
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread Thiago H. de Paula Figueiredo
On Fri, 23 Sep 2011 10:23:50 -0300, Boris Horvat  
 wrote:



I probably din't explain it very well.


I disagree. :) I guess I haven't explained my suggestion well.


I have component with two submit links in it. I also have a page that
includes 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.


This happens because you're specifying the component id in your event  
handler method, which is local to the component or page at which it was  
declared.



Is there a way to push the event from the component up to the page?


Non-render events in components are bubbled to the page unless someone  
handles them in between. Just use event name instead of component id in  
your handler method, as I've suggested before. ;)





In your page:

void onEvent1() { ... } or void @OnEvent("event1") anyName() { ... }

void onEvent2() { ... } or void @OnEvent("event2") anyOtherName() { ... }


--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
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  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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Handling components event in the page that includes the component

2011-09-23 Thread Chris Poulsen
Events bubble up in the page hierarchy afaik. So you could try to postfix
your handlers with "From"

something like: onActionFromMyComponentId(...) ?

-- 
Chris

On Fri, Sep 23, 2011 at 3:24 PM, bhorvat  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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Handling components event in the page that includes the component

2011-09-23 Thread bhorvat
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org