Foren

How to get keys of hook language.props in another portlet

Joerg Schaefer, geändert vor 8 Jahren.

How to get keys of hook language.props in another portlet

New Member Beiträge: 12 Beitrittsdatum: 21.10.14 Neueste Beiträge
Hi,

i have implemented a hook to add some language.properties to the portal. If i use the class LanguageUtil in another portlet, i am able to get the content of the files.
Now i have the requirement to get all the keys of the language.properties files in my portlet, to iterate and select just specific ones. In the LanguageUtil class there is no such method. I decided to use the class ResourceBundle instead, but i cannot access the language.properties files of the hook. I suppose i cannot access these files due to classloader restrictions.

Has somebody an idea?
thanks
thumbnail
Olaf Kock, geändert vor 8 Jahren.

RE: How to get keys of hook language.props in another portlet

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
In general, applications are isolated from each other. Liferay is configured to be able to reach into those contexts, so that the deployer can do its magic. If you want to retrieve code (I'm counting the resource bundles as code as they live on the classpath) from other applications, you should provide them through a service instead of relying on classloader magic to reach into that application yourself - this will make the feature much more maintainable.
Joerg Schaefer, geändert vor 8 Jahren.

RE: How to get keys of hook language.props in another portlet

New Member Beiträge: 12 Beitrittsdatum: 21.10.14 Neueste Beiträge
Hi Olaf,

thanks. Using a service to do that job seems to be the right direction. But how should i proceed in the service impl?
Normally i would use a snippet like the following one. Portal language files are stored in portal-src in the content folder.

ResourceBundle res = ResourceBundle.getBundle("content.Language", locale);


regards Jörg