tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Riedel <cr.ml...@googlemail.com>
Subject Re: URL Rewriting in Tapestry 5.2
Date Wed, 07 Jul 2010 21:55:58 GMT

Am 07.07.2010 um 22:02 schrieb Thiago H. de Paula Figueiredo:

> On Wed, 07 Jul 2010 15:35:51 -0300, Christian Riedel <cr.mlist@googlemail.com>
>> Of course, I have to call both methods and see whether the result is null or not.
For rewritten incoming requests both decoders will return null as the page name is not known
to tapestry:
>>        if (!componentClassResolver.isPageName(pageName))
>>            return null;
>> So in the end I have to parse it by myself again, right?
> You don't have to parse it yourself as the service already implements it. I'm not following

Well, ok maybe I should provide my example:

In 5.2 your URLRewriter code has been deprecated in favor of the LinkTransformer. If I now
want to add rewriting logic just for pages, I would contribute a custom transformer to "PageRenderLinkTransformer".

The only example I could find for the new API was in Tapestry's tests: org.apache.tapestry5.integration.linktrans.services.AppPageRenderLinkTransformer

Unfortunately this transformer does what I said: it reproduces the logic from ComponentEventLinkEncoder
to get locale and page name. You said I could use "the service", which is ComponentEventLinkEncoder
so I did and got, of course, an exception:

public class HomePageRenderLinkTransformer implements PageRenderLinkTransformer {

    private ComponentEventLinkEncoder componentEventLinkEncoder;
    public HomePageRenderLinkTransformer(ComponentEventLinkEncoder componentEventLinkEncoder)

        this.componentEventLinkEncoder = componentEventLinkEncoder;

    public PageRenderRequestParameters decodePageRenderRequest(Request request) {

        // StackOverFlow is coming next...
        final PageRenderRequestParameters decodePageRenderRequest = componentEventLinkEncoder.decodePageRenderRequest(request);
        return decodePageRenderRequest;

So I just can't use it! :) In 5.1 it could have been possible to use the ComponentEventLinkEncoder,
but It won't return anything else than the Index page...

    public Request process(Request request, URLRewriteContext context) {

        // request.getPath = /Home
        final PageRenderRequestParameters decodePageRenderRequest = componentEventLinkEncoder.decodePageRenderRequest(request);
        // decodePageRenderRequest.getLogicalPageName() = Index
        // parse the path once more by hand... 

I hope you are with me now ;)

>> Maybe we just need a thin layer around PageRenderRequestParameters and ComponentEventRequestParameters
that would resolve getPageName() by also looking into contributed URLRewriting rules.
> This is not possible, as Tapestry doesn't know the logic inside rewriting rules.
>> Or the ComponentClassResolver returns true for the rewritten page name... I don't
know what would be best :)
> The URL ComponentClassResolver receives in the normal Tapestry flow is the already rewritten
one. All rewriting is done before the dispatchers are executed, so they never receive the
original, non-rewritten URLs. This should be left as it is, as it simplifies the framework
a lot.
> -- 
> 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: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org

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

View raw message