You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alfonso Quiroga <al...@gmail.com> on 2009/08/21 08:22:49 UTC

creating new component+events

Hi! I've created simple components, and no problem. Now I want to
create a kind of "grid" component, and I want to ask something:
If I want this new component to have pagination... I need something
like FIRE an event (from the component) , and then RECEIVE (handle)
that event  in the component and update it (I don't need AJAX, it
isn't neccesary)

I read http://tapestry.apache.org/tapestry5/guide/event.html... and I
understood that only pages can handle events... but I need the
component handle the event. Any help? Thanks in advanced, and sorry
for my english!

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


Re: creating new component+events

Posted by Alfonso Quiroga <al...@gmail.com>.
Onno: thank you!! In my case, my custom component will not use forms,
just text, images, and event-links. Thanks for your fast feedback :-)
I am starting to love components (I come from struts world).

thanks

On Fri, Aug 21, 2009 at 4:49 AM, Onno Scheffers<on...@piraya.nl> wrote:
>>
>> I read http://tapestry.apache.org/tapestry5/guide/event.html... and I
>> understood that only pages can handle events... but I need the
>> component handle the event. Any help? Thanks in advanced, and sorry
>> for my english!
>
>
>
> Components can handle events as well. For pagination, you can create
> EventLinks from within your component (
> http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/EventLink.html
> ).
>
> When the user clicks on them, the event-handler on your component is called.
> You can use the context parameter to provide a page-number to jump to for
> example and the event-parameter to set the event you want to respond to.
> Then the on[EVENT] method is called on your component.
>
> The problems I've had in the beginning with event-handling in Components
> mostly had to do with events only bubbling up.
> If you setup the form-component on your page and then inside that form you
> have a custom component that uses some fields, your custom component will
> not get any of the form-events.
> The form was setup on the page, so only the form itself and the page will
> get those events. This is very tricky when you setup more complex reusable
> component that need to perform cross-field validation. In those situations
> one want to let the custom component handle complex validation using the
> onSubmit-event, but your handler will never get called.
>
> regards,
>
> Onno
>

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


Re: creating new component+events

Posted by Onno Scheffers <on...@piraya.nl>.
>
> I read http://tapestry.apache.org/tapestry5/guide/event.html... and I
> understood that only pages can handle events... but I need the
> component handle the event. Any help? Thanks in advanced, and sorry
> for my english!



Components can handle events as well. For pagination, you can create
EventLinks from within your component (
http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/EventLink.html
).

When the user clicks on them, the event-handler on your component is called.
You can use the context parameter to provide a page-number to jump to for
example and the event-parameter to set the event you want to respond to.
Then the on[EVENT] method is called on your component.

The problems I've had in the beginning with event-handling in Components
mostly had to do with events only bubbling up.
If you setup the form-component on your page and then inside that form you
have a custom component that uses some fields, your custom component will
not get any of the form-events.
The form was setup on the page, so only the form itself and the page will
get those events. This is very tricky when you setup more complex reusable
component that need to perform cross-field validation. In those situations
one want to let the custom component handle complex validation using the
onSubmit-event, but your handler will never get called.

regards,

Onno