Foros de discusión

Portlet settings (programatically) : classes to use & database storage

thumbnail
M. Garcia, modificado hace 12 años.

Portlet settings (programatically) : classes to use & database storage

Regular Member Mensajes: 107 Fecha de incorporación: 17/05/11 Mensajes recientes
Hello everyone,

I'd like to know what classes I should use to handle the following programmatically, and also where are those settings stored in the database :

- setting an Asset Publisher to ignore shared parameters such as categoryId / tag (this can be done manually accessing portlet Configuration / Communication tab)
- managing a portlet look&feel (this can be done manually accessing portlet Look and Feel)

The look & feel appears to be stored in PortletPreferences : <portlet-setup-css> field.
I didn't find where shared parameters "ignorance" are stored.

Then, what's the proper way to update some PortletPreferences ? Do I have to retrieve all the XML and parse it myself to update the preference fields I need to ? (Using PortletPreferencesLocalServiceUtil.updatePreferences() )


Thanks a lot =)

PS: using Liferay 6.0.6 CE + Tomcat 6 + Oracle 11g
thumbnail
M. Garcia, modificado hace 12 años.

RE: Portlet settings (programatically) : classes to use & database storage

Regular Member Mensajes: 107 Fecha de incorporación: 17/05/11 Mensajes recientes
Anyone.. ?
thumbnail
M. Garcia, modificado hace 12 años.

RE: Portlet settings (programatically) : classes to use & database storage

Regular Member Mensajes: 107 Fecha de incorporación: 17/05/11 Mensajes recientes
A hint on this topic would be much appreciated =)
Thanks
thumbnail
Sandeep Nair, modificado hace 12 años.

RE: Portlet settings (programatically) : classes to use & database storage

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
You have to get PortletPreferences programatically and update the preference. For example in case of shared parameter for AssetPublisher (categoryid and tagname) you can see the logic in EditPublicRenderParametersAction

PortletPreferences preferences =
			PortletPreferencesFactoryUtil.getLayoutPortletSetup(
				layout, portlet.getPortletId());

		Enumeration<string> enu = preferences.getNames();

		while (enu.hasMoreElements()) {
			String name = enu.nextElement();

			if (name.startsWith(
					PublicRenderParameterConfiguration.IGNORE_PREFIX) ||
				name.startsWith(
					PublicRenderParameterConfiguration.MAPPING_PREFIX)) {

				preferences.reset(name);
			}
		}

		for (PublicRenderParameter publicRenderParameter :
				portlet.getPublicRenderParameters()) {

			String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(
				publicRenderParameter);

			boolean ignoreValue = ParamUtil.getBoolean(
				actionRequest, ignoreKey);

			if (ignoreValue) {
				preferences.setValue(ignoreKey, String.valueOf(Boolean.TRUE));
			}
			else {
				String mappingKey =
					PublicRenderParameterConfiguration.getMappingKey(
						publicRenderParameter);

				String mappingValue = ParamUtil.getString(
					actionRequest, mappingKey);

				if (Validator.isNotNull(mappingValue)) {
					preferences.setValue(mappingKey, mappingValue);
				}
			}
		}

		if (SessionErrors.isEmpty(actionRequest)) {
			preferences.store();
		}</string>


The ignore key is the name of the public render parameter which in your case is categoryId and tag respectively.

Regards,
Sandeep