掲示板

Setting global portlet preferences

7年前 に Jordan Miles によって更新されました。

Setting global portlet preferences

Junior Member 投稿: 27 参加年月日: 15/01/22 最新の投稿
I've been playing around with creating portlet preferences with this guide:
https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/using-configurable-portlet-preferences#step-2

and it works great. However, if I set preferences for a portlet, they are only good for that instance of the portlet. If I remove the portlet and re-add it to the page, I have to set the preferences again. Likewise, if I deploy the portlet to another page, I have to set the preferences. Is there a way to give preferences to the portlet as a whole or set default configuration settings for a portlet?
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Setting global portlet preferences

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
You should be leveraging PrefsParamUtil to get your preference value. The getters take an optional default value to use. As long as you're passing in reasonable defaults, you should get something logical regardless if the user has invoked the config page to set values or not.
thumbnail
7年前 に Jack Bakker によって更新されました。

RE: Setting global portlet preferences

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
I usually introduce a database table which I call 'global' which has a name and a value column (for strings). I then can set properties differently in various environments like production, staging, development. 'isDebug', 'isMyPortletDebug', 'mailHost', 'mailHostDebug' and so on.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Setting global portlet preferences

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
The only thing I don't like about this is that typically you'll have a different database for each server instance so you're replicating rows across all of your databases that are not necessary.

They also fail when you cannot get a DB connection.

And often times you have to have an interface to maintain these values so you end up making more work for yourself.

Properties have their place and, just in my opinion, that place is the properties file. Easyconf (the props file config package used by Liferay) is extremely powerful and handles properties far better than a database approach.
thumbnail
7年前 に Jack Bakker によって更新されました。

RE: Setting global portlet preferences

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
I use portal properties, portlet properties (preferences), and then additionally I usually involve the global table I commented on. The global table (or whatever you want to call it) allows those in the IT department(s) of clients adjust values themselves without needing to go to the developer. And just like the Control Panel manages many portal properties, and just like a edit mode can be created to manage portlet preferences per instance, a custom management utility 'could' be coded to manage my global table values. I like putting more control in the hands of the business client web administrators. Note that what I am sharing here is my preferred approach to supplement what Liferay provides which is already very powerful and granular.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Setting global portlet preferences

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
Jack Bakker:
The global table allows those in the IT department(s) of clients adjust values themselves without needing to go to the developer.


Are you embedding the properties file within the build w/o providing an override path?

For example, Liferay often looks for a portlet.properties file and we all get used to just including that file in the source.

However, you can add "include-and-override=my-portlet-override.properties" line to your portlet.properties file and, at run time, Liferay will go looking for this in all of the usual places.

So you can externalize this file, place it in the same location as portal-ext.properties. That way IT can still override the properties, no developer is involved, and they are also located in a common location.

Note I'm not discounting the "global table" concept. It's a valid option that solves this problem and other use cases. My opinion is just that for many scenarios it can be overkill.

For those that aren't aware, I must also point out that Jack and I are friends. I may be acting as his foil here, but I always respect his perspective emoticon
thumbnail
7年前 に Jack Bakker によって更新されました。

RE: Setting global portlet preferences

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
David H Nebinger:
Jack Bakker:
The global table allows those in the IT department(s) of clients adjust values themselves without needing to go to the developer.

Are you embedding the properties file within the build w/o providing an override path?

global table (not file) in a second database (a 'biz database' as I call it)... I call the lportal* database the first database.
David H Nebinger:

For example, Liferay often looks for a portlet.properties file and we all get used to just including that file in the source.

However, you can add "include-and-override=my-portlet-override.properties" line to your portlet.properties file and, at run time, Liferay will go looking for this in all of the usual places.

So you can externalize this file, place it in the same location as portal-ext.properties. That way IT can still override the properties, no developer is involved, and they are also located in a common location.

Good ideas for some, maybe, but going digging for a text file somewhere can be more awkward for many than say managing a database table.
David H Nebinger:

Note I'm not discounting the "global table" concept. It's a valid option that solves this problem and other use cases. My opinion is just that for many scenarios it can be overkill.

In many scenarios many things can be overkill. Ahem...
David H Nebinger:

For those that aren't aware, I must also point out that Jack and I are friends. I may be acting as his foil here, but I always respect his perspective emoticon


Mr. Anderson, we missed you. emoticon