You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mike Dunbar <mi...@lithium.com> on 2012/04/09 17:51:19 UTC

Need Help With Event URL Rewriting

Hi,
We are trying to build an application with RESTful URLs, rather than the out-of-box Tapestry URLs. We've been able to do this for our page URLs by using Tynamo tapestry-routing (http://tynamo.org/tapestry-routing+guide). We would like to do the same thing for the event link URLs contained on our pages. I'm experimenting with ComponentEventLinkEncoder and have been able to use createComponentEventLink to return an event Link with an arbitrary URL. However, when the link is clicked Tapestry does not recognize this as a component event request, and hence doesn't call the decodeComponentEventRequest method in my ComponentEventLinkEncoder. Could someone please point me in the right direction to both:

- Generate an arbitrary URL for an event (this part is working).
- Have tapestry recognize the 'click' of that same arbitrary URL as an event, so I can route it to my event handler method (not yet working).

Thanks,
Mike

Re: Need Help With Event URL Rewriting

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 09 Apr 2012 15:03:26 -0300, Mike Dunbar <mi...@lithium.com>  
wrote:

> Hi Thiago, Thanks for your response. My replies inline below. -Mike
>
>> Why aren't the Tapestry URLs RESTful enough for your scenario? Using  
>> PUT, DELETE, etc? Just curious. :)
>
> I may be using the term 'RESTful' incorrectly. What I meant is suppose I  
> have a page that displays the details of an order item, order ID is 5  
> and item number is 2. Out of the box, Tapestry uses URLs like  
> 'http://host:port/appcontext/OrderItemDetails/5/2'. We want URLs like  
> 'http://host:port/appcontext/order/5/item/2'. So the path has nothing to  
> do with my fully qualified page class name and the parameters don't have  
> to come at the end of the URL. Make sense?

It does, but you can use Tapestry's LinkTransformer API for that, Tynamo  
Routing is another option.

>
>> Why [do you want to extend this to event URLs]? Event URLs aren't meant  
>> to be used outside Tapestry applications themselves.
>
> I think the main idea is that we'd like the links that users see on  
> hover to not look so radically different from the page URLs. It may be  
> enough to make sure that the event URLs have the page part of the path  
> in our desired format and the event part of the path can be in standard  
> Tapestry format, e.g.  
> '/order/5/item/2<http://host:port/appcontext/order/5/item/2>.remove'. We  
> may not also require that the event part of the path be non-standard,  
> e.g. '/order/5/item/2/remove'.

Again, LinkTransformer API. :)

>> You can't do [that] directly. Instead, you'll need to use the  
>> LinkTransformer API to rewrite the component event links to what you  
>> want.
>
> I don't think LinkTransformer will do anything more than  
> ComponentEventLinkEncoder, which has pretty much the same 4 methods for  
> both decoding page and component event requests, and  
> creating/transforming links for page and component event requests.

But that's exactly what is needed for you problem (unless I'm overlooking  
something).
I still think LinkTransformer is the solution for your problems. You said  
it wouldn't working without trying. Try it. :)

> Creating/Transforming the links is absolutely working, but since the  
> links I build for events do not conform to what Tapestry expects – i.e.  
> look like ‘pathtopage.eventid’ – the click of the link isn’t recognized  
> as a component event request.

Don't forget that you need to rewrite both outgoing (Tapestry created  
URLs) and incoming (URLs received by Tapestry) URLs, both page render and  
component ones.

-- 
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: Need Help With Event URL Rewriting

Posted by Mike Dunbar <mi...@lithium.com>.
Hi Thiago, Thanks for your response. My replies inline below. -Mike

> Why aren't the Tapestry URLs RESTful enough for your scenario? Using PUT, DELETE, etc? Just curious. :)

I may be using the term 'RESTful' incorrectly. What I meant is suppose I have a page that displays the details of an order item, order ID is 5 and item number is 2. Out of the box, Tapestry uses URLs like 'http://host:port/appcontext/OrderItemDetails/5/2'. We want URLs like 'http://host:port/appcontext/order/5/item/2'. So the path has nothing to do with my fully qualified page class name and the parameters don't have to come at the end of the URL. Make sense?

> Why [do you want to extend this to event URLs]? Event URLs aren't meant to be used outside Tapestry applications themselves.

I think the main idea is that we'd like the links that users see on hover to not look so radically different from the page URLs. It may be enough to make sure that the event URLs have the page part of the path in our desired format and the event part of the path can be in standard Tapestry format, e.g. '/order/5/item/2<http://host:port/appcontext/order/5/item/2>.remove'. We may not also require that the event part of the path be non-standard, e.g. '/order/5/item/2/remove'.

> You can't do [that] directly. Instead, you'll need to use the LinkTransformer API to rewrite the component event links to what you want.

I don't think LinkTransformer will do anything more than ComponentEventLinkEncoder, which has pretty much the same 4 methods for both decoding page and component event requests, and creating/transforming links for page and component event requests. Creating/Transforming the links is absolutely working, but since the links I build for events do not conform to what Tapestry expects – i.e. look like ‘pathtopage.eventid’ – the click of the link isn’t recognized as a component event request.


Re: Need Help With Event URL Rewriting

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 09 Apr 2012 12:51:19 -0300, Mike Dunbar <mi...@lithium.com>  
wrote:

> Hi,

Hi!

> We are trying to build an application with RESTful URLs, rather than the  
> out-of-box Tapestry URLs.

Why aren't the Tapestry URLs RESTful enough for your scenario? Using PUT,  
DELETE, etc? Just curious. :)

> We've been able to do this for our page URLs by using Tynamo  
> tapestry-routing (http://tynamo.org/tapestry-routing+guide). We would  
> like to do the same thing for the event link URLs contained on our pages.

Why? Event URLs aren't meant to be used outside Tapestry applications  
themselves.

> - Have tapestry recognize the 'click' of that same arbitrary URL as an  
> event, so I can route it to my event handler method (not yet working).

You can't do that directly. Instead, you'll need to use the  
LinkTransformer API to rewrite the component event links to what you want.

-- 
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