Fórum

custom properties in hook

Jan Delannoy, modificado 14 Anos atrás.

custom properties in hook

Junior Member Postagens: 25 Data de Entrada: 18/01/10 Postagens Recentes
Hi all,

I'm trying to find a "standard" way to define custom properties in a hook that overrides the journal portlet. I made some changes to some of the JSPs of the journal portlet and want to use some custom properties in there. When I tried to use Easyconf I noticed that Easyconf can't find my properties file because the JSPs are copied to the ROOT webapp and run from there while my properties file stays in the webapp of my hook. Then I've looked at an article on the wiki (http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Adding+Custom+Properties) but this seems to be outdated.

I guess I could tweak my build by moving my properties file to the EXT environment so that it gets deployed to the ROOT webapp together with portal-ext.properties, but this just doesn't feel right.

Any suggestions anyone?

Many thanks,
Jan
thumbnail
Dong-Jun Kim, modificado 14 Anos atrás.

RE: custom properties in hook

Junior Member Postagens: 61 Data de Entrada: 23/12/09 Postagens Recentes
Hi Jan,

I guess you have already looked at this link. If you haven't it would be helpful for you.
Hook Plugins

One thing to note is that you need to use correct DTD version (if you haven't checked it) which I missed when I worked on Liferay Hook Plugins to extend properties file. If the hook is configured correctly, it should overwrite portal.properties as if you extended it using ext environment.

Hope this helps.

Regards,
Dong-Jun
Jan Delannoy, modificado 14 Anos atrás.

RE: custom properties in hook

Junior Member Postagens: 25 Data de Entrada: 18/01/10 Postagens Recentes
Hi Dong-Jun,

Thanks for your answer. How can I access these properties in my code? For example, suppose I have a new property called 'myCustomProperty' and I add it to the portlet.properties file as you suggest, how can I access this property in my JSPs? Is there some method available? Or are these properties available as request attributes or something?

Many thanks,
Jan
thumbnail
Dong-Jun Kim, modificado 14 Anos atrás.

RE: custom properties in hook (Resposta)

Junior Member Postagens: 61 Data de Entrada: 23/12/09 Postagens Recentes
Following is one of many samples available in Liferay source code.

...
PropsUtil.get(PropsKeys.TRANSLATOR_DEFAULT_LANGUAGES), StringPool.BLANK, StringPool.BLANK
...


You can create a constants in PropsKeys with the custom property name such as
My_CUSTOM_PROPERTY_KEY=my.custom.property
with a value for the property assigned in portal.properties file in your hook plugin, then you can use the above syntax to utilize the value in your java file or jsp file. PropsUtil is imported portal level, so you should be able to use it without any import statement in your jsp file.

FYI, if you would like to see more example, Liferay source code has quite many examples already.

Hope this answers to your question.

Regards,
Dong-Jun
thumbnail
Dong-Jun Kim, modificado 14 Anos atrás.

RE: custom properties in hook

Junior Member Postagens: 61 Data de Entrada: 23/12/09 Postagens Recentes
If you would like to directly access the property, you can just use the property name directly instead of having it in constants file. Although, it is recommended to have it in constants class in terms of code maintainability. You can extend the constants class using either ext environment or ext plugin depending on the version of Liferay that you are working on.
Jan Delannoy, modificado 14 Anos atrás.

[RESOLVED] RE: custom properties in hook

Junior Member Postagens: 25 Data de Entrada: 18/01/10 Postagens Recentes
Thanks mate, just what I needed! emoticon
thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

RE: [RESOLVED] RE: custom properties in hook

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
If I am using Hook for doing this I will need to overeride the liferays' PropsKeys with my string for key value in portal.poperties
does ,merely mirroring the path of PropsKeys in hook in java package src will do or I need to do something extra ?