You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dimitris Zenios <di...@gmail.com> on 2014/09/01 23:07:17 UTC

Custom MessageSource

Hello everyone

I am trying to find ways in order to contribute custom message sources
other than properties file (Database for example).Is there an easy way to
achieve that other than overriding ComponentMessagesSource service?

I started by viewing the  tapestry-core code and I found out that
ComponentMessagesSource uses MessageSource in order to get the Messages but
unfortunately MessagesSourceImpl cannot be overridden since its not
declared as normal tapestry service but constructed at
ComponentMessagesSourceImpl constructor

My final goal would be to use apache-configuration for messages.

Cheers.

Re: Custom MessageSource

Posted by Dimitris Zenios <di...@gmail.com>.
Thanks for the quick reply

I was hoping something like contributeMessageSource.Unfortunately I have to
work it out through decorators/advisors.

In my opinion contributing MessageSources is something that its good for
tapestry to have.


On Tue, Sep 2, 2014 at 12:29 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 01 Sep 2014 18:07:17 -0300, Dimitris Zenios <
> dimitris.zenios@gmail.com> wrote:
>
>  Hello everyone
>>
>
> Hi!
>
>
>  I am trying to find ways in order to contribute custom message sources
>> other than properties file (Database for example).Is there an easy way to
>> achieve that other than overriding ComponentMessagesSource service?
>>
>
> Yes!
>
>
>  I started by viewing the  tapestry-core code and I found out that
>> ComponentMessagesSource uses MessageSource in order to get the Messages
>> but unfortunately MessagesSourceImpl cannot be overridden since its not
>> declared as normal tapestry service but constructed at
>> ComponentMessagesSourceImpl constructor
>>
>
> MessagesSource and MessagesSourceImpl are internal classes and you should
> avoid using them directly. In addition, you don't need them at all. All you
> need to do is to:
>
> 1) Write your own Messages implementation, say MyMessages.
> 2) Decorate or advise ComponentMessagesSource to return MyMessages
> according to the logic you want in the methods that return Messages.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Custom MessageSource

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 01 Sep 2014 18:07:17 -0300, Dimitris Zenios  
<di...@gmail.com> wrote:

> Hello everyone

Hi!

> I am trying to find ways in order to contribute custom message sources
> other than properties file (Database for example).Is there an easy way to
> achieve that other than overriding ComponentMessagesSource service?

Yes!

> I started by viewing the  tapestry-core code and I found out that
> ComponentMessagesSource uses MessageSource in order to get the Messages  
> but unfortunately MessagesSourceImpl cannot be overridden since its not
> declared as normal tapestry service but constructed at
> ComponentMessagesSourceImpl constructor

MessagesSource and MessagesSourceImpl are internal classes and you should  
avoid using them directly. In addition, you don't need them at all. All  
you need to do is to:

1) Write your own Messages implementation, say MyMessages.
2) Decorate or advise ComponentMessagesSource to return MyMessages  
according to the logic you want in the methods that return Messages.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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