You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jochen Frey <jo...@jochenfrey.com> on 2012/02/02 03:07:58 UTC
Re: URL Rewriting
So I dug through the source code, and the custom link transformation is spliced in by way of an interceptor pattern (in TapestryModule):
@Match("ComponentEventLinkEncoder")
public ComponentEventLinkEncoder decorateLinkTransformer(LinkTransformer linkTransformer,
ComponentEventLinkEncoder delegate)
{
return new LinkTransformerInterceptor(linkTransformer, delegate);
}
Where the linkTransformer splices in a Chain of Command that can be configured as per Igor's blog post.
The problem I am wrestling with is that when I implement a LinkTransformer myself in which I only want to rewrite the basepath and leave activation contexts etc alone, I still have to replicate all functionality that the original ComponentEventLinkEncoderImpl has (I could copy the source code, but that seems unclean at best).
Alternatively (and that's what I am trying to figure out how to do), I could do something like this in my own LinkTransformer:
public PageRenderRequestParameters decodePageRenderRequest(Request request)
{
PageRenderRequestParameters original = originalComponentEventLinkEncoder.decodePageRenderRequest(request);
// build my own based on the original one ...
So how do I get the "original" ComponentEventLinkEncoderImpl? When I @Inject or @InjectService, I get the interceptor (see all the way on top of this mail), which results in an endless loop (my code keeps calling the interceptor, which in turn calls my code). It seems like the only way of doing this is actually doing a:
ComponentEventLinkEncoder myPrivateEncoder = new ComponentEventLinkEncoderImpl( .... )
... which seems to be unclean ... or is that the way to do it?
Thanks!
Jochen
On Jan 31, 2012, at 10:52 AM, Thiago H. de Paula Figueiredo wrote:
> On Tue, 31 Jan 2012 15:53:29 -0200, Jochen Frey <jo...@jochenfrey.com> wrote:
>
>> Excellent!
>>
>> But what let's say there's a 2nd link transformer, what happens to the PageRenderRequestParameters that the two transformers return? Would the second one just inject an EventContext
>
> The PageRenderRequestParameters returned by the first will be passed to the next. I haven't looked at the code, but that's what I expect it to do. That's what the old URL rewriter code did: the Request returned by one rule was passed to the next rule until all rules were executed.
>
> --
> 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
---
jochen@jochenfrey.com
+1.415.366.0450
@jochen_frey
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org