Re: T5: accessing another page/component's message catalog

2008-04-25 Thread Adam Zimowski
Thanks Waldo! This solves my problem exactly how I needed to attack
it. The little extra code doesn't bother me, it's just how it's done.
I simply didn't know enough about Tapestry, specifically
ComponentMessagesSource and ComponentSource interfaces!

Thanks again, this rocks.

On Thu, Apr 24, 2008 at 1:52 PM, Waldo Mendoza
<[EMAIL PROTECTED]> wrote:
>
> Adam Zimowski  gmail.com> writes:
>
>  >
>  > Is there a way to access message catalog of some page or component
>  > from another page or component? I know of two ways to do this, but
>  > both are "hacks" IMHO:
>  >
>  > class SomePage {
>  >
>  > @Inject
>  > private Messages _messages;
>  >
>  > public getMessages() {
>  >  return _messages;
>  > }
>  > }
>  >
>  > class Foo {
>  >
>  > @InjectPage
>  > private SomePage _page;
>  >
>  > // now I can access messages from _page
>  > }
>  >
>  > Above way is a pain because every page/component needs to explicitly
>  > expose message catalog for use by other page. Another way to do this
>  > would be to obtain page/component resource path, and do it
>  > old-fashioned way with java.util.Property - ughh... !
>  >
>  > What I was looking for is some support by Messages, perhaps overriden
>  > method get(String key):
>  >
>  > Messages.get(String resourcePath, String key)
>  > Messages.get(Class component, String key)
>  >
>  > The thing is, that I need to read another componen't message catalog
>  > not knowing ahead of time what the comopnent is. I don't see a "clean"
>  > way of doing it at the moment, any ideas?
>  >
>  > -adam
>  >
>  > -
>  > To unsubscribe, e-mail: users-unsubscribe  tapestry.apache.org
>  > For additional commands, e-mail: users-help  tapestry.apache.org
>  >
>  >
>
>
>  Hello Adam
>
>  One posibility is to Inject ComponentSource and ComponentMessageSource, after
>  that you can use ComponentSource to get the page by name, and use
>  ComponentMessageSource to get the page Messages, something like:
>
>  private ComponentMessagesSource _componentMessageSource;
>
>  private ComponentSource _componentSource;
>
>  ...
>  Component page = _componentSource.getPage("foo");
>  Messages messages = _componentMessageSource.getMessages(
> page.getComponentResources().getComponentModel(),
>  page.getComponentResources().getLocale());
>  
>
>
>  Maybe it would be more clean to create a specific service that you can inject
>  to your page.
>
>  Hope this helps.
>  Bye
>
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: accessing another page/component's message catalog

2008-04-24 Thread Waldo Mendoza
Adam Zimowski  gmail.com> writes:

> 
> Is there a way to access message catalog of some page or component
> from another page or component? I know of two ways to do this, but
> both are "hacks" IMHO:
> 
> class SomePage {
> 
> @Inject
> private Messages _messages;
> 
> public getMessages() {
>  return _messages;
> }
> }
> 
> class Foo {
> 
> @InjectPage
> private SomePage _page;
> 
> // now I can access messages from _page
> }
> 
> Above way is a pain because every page/component needs to explicitly
> expose message catalog for use by other page. Another way to do this
> would be to obtain page/component resource path, and do it
> old-fashioned way with java.util.Property - ughh... !
> 
> What I was looking for is some support by Messages, perhaps overriden
> method get(String key):
> 
> Messages.get(String resourcePath, String key)
> Messages.get(Class component, String key)
> 
> The thing is, that I need to read another componen't message catalog
> not knowing ahead of time what the comopnent is. I don't see a "clean"
> way of doing it at the moment, any ideas?
> 
> -adam
> 
> -
> To unsubscribe, e-mail: users-unsubscribe  tapestry.apache.org
> For additional commands, e-mail: users-help  tapestry.apache.org
> 
> 


Hello Adam

One posibility is to Inject ComponentSource and ComponentMessageSource, after 
that you can use ComponentSource to get the page by name, and use 
ComponentMessageSource to get the page Messages, something like:

private ComponentMessagesSource _componentMessageSource;

private ComponentSource _componentSource;

...
Component page = _componentSource.getPage("foo");
Messages messages = _componentMessageSource.getMessages(
page.getComponentResources().getComponentModel(), 
page.getComponentResources().getLocale()); 



Maybe it would be more clean to create a specific service that you can inject 
to your page.

Hope this helps.
Bye



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5: accessing another page/component's message catalog

2008-04-24 Thread Adam Zimowski
Is there a way to access message catalog of some page or component
from another page or component? I know of two ways to do this, but
both are "hacks" IMHO:

class SomePage {

@Inject
private Messages _messages;

public getMessages() {
 return _messages;
}
}

class Foo {

@InjectPage
private SomePage _page;

// now I can access messages from _page
}

Above way is a pain because every page/component needs to explicitly
expose message catalog for use by other page. Another way to do this
would be to obtain page/component resource path, and do it
old-fashioned way with java.util.Property - ughh... !

What I was looking for is some support by Messages, perhaps overriden
method get(String key):

Messages.get(String resourcePath, String key)
Messages.get(Class component, String key)

The thing is, that I need to read another componen't message catalog
not knowing ahead of time what the comopnent is. I don't see a "clean"
way of doing it at the moment, any ideas?

-adam

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]