How to set global portal variables in liferay?

I am currently working on a portal and I need to use Liferay as the portal server.

My application will have some global settings that I need to get in all portlets of my portal.

What is the best way to download such configurations? I want these configuration parameters to be read from a configuration file / database. but it should be read only once at application launch. I do not want the settings to be read from the database / file for each request.

Also, I would use speed frames for templates, can I read the same global variables in my speed templates?

Can I put these global variables in my portal-ext.properties file, and if so, how can I load the default values ​​in it?

Any other approaches will also help,

Thank you in advance

+4
source share
2 answers

Add the following to portal -ext.properties:

my.key=myValue 

You can implement PropsKeys for a key:

 public class ExtPortalKeys implements PropsKeys { public static final String MY_KEY = "my.key"; } 

and then call:

 PrefsPropsUtil.getString(companyId, ExtPortalKeys.MY_KEY); 

considers

+4
source

One approach would be to use an action hook to log into the system.

Define your class in the portal -ext.properties file

login.events.post = com.xxx.PostLoginAction

In the class, you can read the configuration or properties from a file / database. You can set them as some global session values ​​that can be shared by all portlets.

Additional information on post-logon actions and sharing sessions is available at the links below.

http://www.liferay.com/community/wiki/-/wiki/Main/Custom+Post-login+Redirect

http://www.liferay.com/community/wiki/-/wiki/Main/Session+Sharing

0
source

Source: https://habr.com/ru/post/1387526/


All Articles