You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Ludwig <ge...@gmail.com> on 2013/04/05 21:16:58 UTC

Acces page properties file within a component?

I'm building a custom component, and want to render field labels similar to
how the Tapestry components do, by reading a <fieldname>.<label> parameter
from the page's .properties file.

Is there an easy way to read the properties file from within a component? I
can get ComponentResources, and that will get me the MessageCatalogue, but
that's not the same thing, is it?

Re: Acces page properties file within a component?

Posted by George Ludwig <ge...@gmail.com>.
I got a chance to look in to this a little more. Thiago, from your email,
it sounded like you were saying that there was an automatic hierarchical
reading of properties, but testing indicates that reading the message
catalog within a component only gives access to the component level
properties.

I.e., the following code within a component will only "see" the component
properties:

@Inject
private Messages messages;
...
messages.get(someKey);


I looked in the code for the BeanEditForm, and it's doing this, which makes
perfect sense and works fine:

@Inject

private ComponentResources resources;
...
resources.getContainerMessages().get(someKey);

Just posting this in case someone else comes looking for a solution.



On Fri, Apr 5, 2013 at 1:08 PM, George Ludwig <ge...@gmail.com>wrote:

> Thanks!
>
>
> On Fri, Apr 5, 2013 at 12:52 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Fri, 05 Apr 2013 16:16:58 -0300, George Ludwig <ge...@gmail.com>
>> wrote:
>>
>>  I'm building a custom component, and want to render field labels similar
>>> to how the Tapestry components do, by reading a <fieldname>.<label>
>>> parameter from the page's .properties file.
>>>
>>
>> When in a component, messages will be read from the component .properties
>> file first (if it exists), then the page one, then the global one (usually
>> app.properties).
>>
>>
>>  Is there an easy way to read the properties file from within a component?
>>>
>>
>> @Inject
>> private Messages messages;
>>
>>
>>  I can get ComponentResources, and that will get me the MessageCatalogue,
>>> but that's not the same thing, is it?
>>>
>>
>> It is (at least when the message you're using isn't defined in the
>> component's property file).
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: Acces page properties file within a component?

Posted by George Ludwig <ge...@gmail.com>.
Thanks!


On Fri, Apr 5, 2013 at 12:52 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 05 Apr 2013 16:16:58 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>  I'm building a custom component, and want to render field labels similar
>> to how the Tapestry components do, by reading a <fieldname>.<label>
>> parameter from the page's .properties file.
>>
>
> When in a component, messages will be read from the component .properties
> file first (if it exists), then the page one, then the global one (usually
> app.properties).
>
>
>  Is there an easy way to read the properties file from within a component?
>>
>
> @Inject
> private Messages messages;
>
>
>  I can get ComponentResources, and that will get me the MessageCatalogue,
>> but that's not the same thing, is it?
>>
>
> It is (at least when the message you're using isn't defined in the
> component's property file).
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Acces page properties file within a component?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 05 Apr 2013 16:16:58 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> I'm building a custom component, and want to render field labels similar  
> to how the Tapestry components do, by reading a <fieldname>.<label>  
> parameter from the page's .properties file.

When in a component, messages will be read from the component .properties  
file first (if it exists), then the page one, then the global one (usually  
app.properties).

> Is there an easy way to read the properties file from within a component?

@Inject
private Messages messages;

> I can get ComponentResources, and that will get me the MessageCatalogue,  
> but that's not the same thing, is it?

It is (at least when the message you're using isn't defined in the  
component's property file).

-- 
Thiago H. de Paula Figueiredo

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