You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sergey Didenko <se...@gmail.com> on 2009/07/03 16:30:36 UTC

Decoration of setupRender, beginRender from a service

Hi,

is it possible to make something like this?

Component.java:

@Inject DecoratingService service;

void setupRender() {
    logger.info(" I'm not the first... ");
}


DecoratingService.java :

void decorateSetupRender() {
    // somehow decorate hosting component setupRender()
    logger.info( " I'm the first! " );
    hostingComponentSetupRender();
}

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


Re: Decoration of setupRender, beginRender from a service

Posted by Sergey Didenko <se...@gmail.com>.
Turned out Mixins are the perfect tool for this problem. They helped
me to eliminate super.setupRender() calls in the beginning of every
parameterized component setupRender().

Thanks for the clue, Thiago!

On Sun, Jul 5, 2009 at 3:45 PM, Sergey Didenko<se...@gmail.com> wrote:
> Not yet. I needed that to refactor my current handling of request parameters.
>
> Right now I extend my base class ComponentWithParameters and then make
> sure to call
>
> super.setupRender();
>
> in the beginning of component setupRender() method. That is not very
> elegant. Using a special annotation on setupRender() does not
> eliminate this problem. I have to remember to "mark" setupRender()
> anyway.
>
> So right now I just use the first approach. May be the better solution
> would be to annotate the whole component class if it is possible to
> advise component render methods.
>
> On Sun, Jul 5, 2009 at 1:03 AM, Thiago H. de Paula
> Figueiredo<th...@gmail.com> wrote:
>> Em Sat, 04 Jul 2009 04:33:10 -0300, Sergey Didenko
>> <se...@gmail.com> escreveu:
>
>> Have you already implemented what you needed?
>

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


Re: Decoration of setupRender, beginRender from a service

Posted by Sergey Didenko <se...@gmail.com>.
Not yet. I needed that to refactor my current handling of request parameters.

Right now I extend my base class ComponentWithParameters and then make
sure to call

super.setupRender();

in the beginning of component setupRender() method. That is not very
elegant. Using a special annotation on setupRender() does not
eliminate this problem. I have to remember to "mark" setupRender()
anyway.

So right now I just use the first approach. May be the better solution
would be to annotate the whole component class if it is possible to
advise component render methods.

On Sun, Jul 5, 2009 at 1:03 AM, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Sat, 04 Jul 2009 04:33:10 -0300, Sergey Didenko
> <se...@gmail.com> escreveu:

> Have you already implemented what you needed?

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


Re: Decoration of setupRender, beginRender from a service

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, Jul 3, 2009 at 11:30 AM, Sergey Didenko<se...@gmail.com> wrote:
> Hi,

Hi!

> is it possible to make something like this?

This looks like a mixin, but mixins don't decorate components nor pages.

I suggest you to take another approach: create an annotation and write
a ComponentMethodAdvice that decorates methods annotated with that
annotation. Take a look at the Tapestry sources to find where it's
used and have some examples.

-- 
Thiago

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