You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Amaury Willemant <aw...@gmail.com> on 2011/09/06 14:48:46 UTC

Why IdAllocator is not a service ?

Hi everyone,

I am currently working on an implementation of a Liferay portlet using
Tapesty 5.1.0.5 and I need to add a prefix for all the ids written in the
generated HTML and the associated javascript. I knew that Tapestry was able
to add a numeric suffix (xxx_0, xxx_1, etc...) and that is how I discovered
the IdAllocator class and its differents uses in Tapestry.

I was really surprised because it seems to be only a simple POJO, so ? how
to override it with Tapestry IOC ?

The prefix I need to add is a piece of information stored in the Request
service and changes for each request, how to inject it in a clean way ?

I began to write a new service named "IdAllocatorFactory" which provides a
new IdAllocator (that I rewrote to add a prefix field) then I patched all
the classes which instantiate an IdAllocator (Form, FormInjector,
RenderSupport, ...) in order to make them use my brand new factory.

But I feel that it is too much ! Tapestry offers great functionnalities, it
is very easy to extend or override, did I forgot something ? Is it mandatory
to replace so many classes ?

Please ! Tell me that there is an easier and cleaner way to add this prefix
in front of all the HTML Ids ! Please !

Thank you in advance,

Amaury

Re: Why IdAllocator is not a service ?

Posted by Amaury Willemant <aw...@gmail.com>.
Thank you Howard, I hope i did not offended you. I was just joking, the
modifications I realized seem to work and I must admit that it is a real
pleasure to understand Tapestry, the more you dig into the code, the more
you love it ;)



2011/9/6 Amaury Willemant <aw...@gmail.com>

> Hi everyone,
>
> I am currently working on an implementation of a Liferay portlet using
> Tapesty 5.1.0.5 and I need to add a prefix for all the ids written in the
> generated HTML and the associated javascript. I knew that Tapestry was able
> to add a numeric suffix (xxx_0, xxx_1, etc...) and that is how I discovered
> the IdAllocator class and its differents uses in Tapestry.
>
> I was really surprised because it seems to be only a simple POJO, so ? how
> to override it with Tapestry IOC ?
>
> The prefix I need to add is a piece of information stored in the Request
> service and changes for each request, how to inject it in a clean way ?
>
> I began to write a new service named "IdAllocatorFactory" which provides a
> new IdAllocator (that I rewrote to add a prefix field) then I patched all
> the classes which instantiate an IdAllocator (Form, FormInjector,
> RenderSupport, ...) in order to make them use my brand new factory.
>
> But I feel that it is too much ! Tapestry offers great functionnalities, it
> is very easy to extend or override, did I forgot something ? Is it mandatory
> to replace so many classes ?
>
> Please ! Tell me that there is an easier and cleaner way to add this prefix
> in front of all the HTML Ids ! Please !
>
> Thank you in advance,
>
> Amaury
>

Re: Why IdAllocator is not a service ?

Posted by Howard Lewis Ship <hl...@gmail.com>.
You can't predict every use case ... in fact, IMHO, some of the weaker
parts of Tapestry are where we tried to predict how something would be
used, rather than react to new (and valid) use cases.

On Tue, Sep 6, 2011 at 5:48 AM, Amaury Willemant
<aw...@gmail.com> wrote:
> Hi everyone,
>
> I am currently working on an implementation of a Liferay portlet using
> Tapesty 5.1.0.5 and I need to add a prefix for all the ids written in the
> generated HTML and the associated javascript. I knew that Tapestry was able
> to add a numeric suffix (xxx_0, xxx_1, etc...) and that is how I discovered
> the IdAllocator class and its differents uses in Tapestry.
>
> I was really surprised because it seems to be only a simple POJO, so ? how
> to override it with Tapestry IOC ?
>
> The prefix I need to add is a piece of information stored in the Request
> service and changes for each request, how to inject it in a clean way ?
>
> I began to write a new service named "IdAllocatorFactory" which provides a
> new IdAllocator (that I rewrote to add a prefix field) then I patched all
> the classes which instantiate an IdAllocator (Form, FormInjector,
> RenderSupport, ...) in order to make them use my brand new factory.
>
> But I feel that it is too much ! Tapestry offers great functionnalities, it
> is very easy to extend or override, did I forgot something ? Is it mandatory
> to replace so many classes ?
>
> Please ! Tell me that there is an easier and cleaner way to add this prefix
> in front of all the HTML Ids ! Please !
>
> Thank you in advance,
>
> Amaury
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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