Hello,

Following a suggestion from a fellow T5 user (cheers Nicolas!) I've
changed my page name injecting strategy. I now have a
ComponentClassTransformWorker which adds a Mixin to every Page
component. This Page Mixin (in the afterRender() method) then injects
the page name as a comment in the Document model.

This has the benefit of injecting the name of the "rendered page" as
oppose to the name of the requested page. The important difference is
that on error pages (http 404 and 500) I now inject the names of the
error pages and not what the user originally asked for.

What I'd like to know now, is there a "nice" way, in the
ComponentClassTransformWorker to check if I'm transforming a page?

Both of the following work, but neither seem particularly pleasant:

@Inject
private ComponentClassResolver  resolver;
        
try {
        resolver.resolvePageClassNameToPageName(transformation.getClassName());
} catch (IllegalArgumentException e) {
        // not a page... goodbye!
        return;
}

... or...

if (!transformation.getClassName().contains(".pages."))
        // not a page... goodbye!
        return;

Any ideas?

Cheers,

Steve.



On 7 May 2010 12:00, Steve Eynon <steve.ey...@googlemail.com> wrote:
> Thanks for the help and a quick response! The following gives me what
> I need inside a MarkupRendererFilter:
>
> @Inject
> private Request request;
>
> @Inject
> private ComponentEventLinkEncoder linkEncoder;
>
> @Inject
> private ComponentClassResolver classResolver;
>
> String logicalPageName =
> linkEncoder.decodePageRenderRequest(request).getLogicalPageName();
> String actualPageName = classResolver.canonicalizePageName(logicalPageName);
>
> Cheers,
>
> Steve.
> --
> Steve Eynon
> mobie: (+592) 678 4236
>
>
>
> On 7 May 2010 10:25, Thiago H. de Paula Figueiredo <thiag...@gmail.com> wrote:
>> On Fri, 07 May 2010 11:05:56 -0300, Dmitry Gusev <dmitry.gu...@gmail.com>
>> wrote:
>>
>>> public void
>>> contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter>
>>> configuration,
>>>                                         final MetaDataLocator
>>> metaDataLocator,
>>>                                         final ComponentEventLinkEncoder
>>> linkEncoder,
>>>                                         final RequestGlobals globals)
>>>    {
>>>        configuration.add(NO_MARKUP_SYMBOL,
>>>            new MarkupRendererFilter()
>>>            {
>>>               �...@override
>>>                public void renderMarkup(MarkupWriter writer,
>>> MarkupRenderer
>>> renderer) {
>>>                    PageRenderRequestParameters parameters =
>>> linkEncoder.decodePageRenderRequest(globals.getRequest());
>>
>> Instead of injecting RequestGlobals, you can inject Request directly.
>>
>>> Not sure if this available in T5.1, but you can try this. I believe
>>> "parameters.getLogicalPageName()" is what you need.
>>
>> It is.
>>
>> --
>> 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
>>
>>
>

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

Reply via email to