PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: akmansoor on November 10, 2008, 03:35:06



Title: How to use resourceManager in Mediators
Post by: akmansoor on November 10, 2008, 03:35:06
I am using resourceManager in my views using resourceManager.getString("myResource","myLabel")
How do I use the same in my mediators.

Thanks,
Mansoor Achire


Title: Re: How to use resourceManager in Mediators
Post by: puremvc on November 10, 2008, 05:11:25
The exact same way. Its just a question of what you do with the resource string afterwards. in the mediator you'd make the call and set the result on a public property of the view component.

Its best not to have the mediator set somedeeply nested implementation specific property like "myComp.mainPanel.tititle" but instead to expose a bindable public top level property in MyComp like instanceTitle and have the mediator set that property. Thin inside MyComp, have mainPanel's title property bind to instanceTitle. This encapsulates the component implementation specifics and exposes a clear API for its client (the mediator) to deliver the required resources.

Later, if the component is refactored to use some other implementation and mainPanel goes away, the mediator will not fail or have to be modified beyond changes you may make to the actual resource property names.

-=Cliff> 


Title: Re: How to use resourceManager in Mediators
Post by: akmansoor on November 11, 2008, 07:57:20
I am not able to use resourceManager in mediators, it is giving compilation error undefined property. In view I am able to use it.


Title: Re: How to use resourceManager in Mediators
Post by: akmansoor on November 11, 2008, 09:02:52
I understood that resourceManager is part of UIcomponent. This is why i am not able to access it in my mediator.
It works when I try
ResourceManager.getInstance().getString("resources", "myKey");

Thanks,
Mansoor Achire