Forum

Accueil » Liferay Portal » English » 3. Development

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Rashidi Zin
[SOLVED] Portlet's Look and Feel Overwrites Configuration
9 septembre 2013 18:12
Réponse

Rashidi Zin

Rang: New Member

Publications: 3

Date d'inscription: 14 juin 2013

Publications Récentes

Hello all.

I am trying to develop a portlet which allows users to specify their own settings. For this I am using DefaultConfigurationAction. Things works as expected when I tested it without any changes to Look and Feel.

However when I specify a page to be linked to (Look and Feel -> Link Portlet URL to Page) all settings entered by user are gone. Through debugging mode I found that ResourceRequest.getPreference returns empty result although I have provided values for them in the portlets.

Is there a fix for this?

Thanks in advanced for all your helps.
Kan Zhang
RE: Portlet's Look and Feel Overwrites Configuration
9 septembre 2013 15:08
Réponse

Kan Zhang

Rang: Junior Member

Publications: 66

Date d'inscription: 1 décembre 2010

Publications Récentes

The resourceRequest is usually being used when serving an ajax call. Are you using the ResourceRequest.getPreference for some specific reason? If not, there is a most common way to get the portlet preferences:

1PortletPreferences preferences = renderRequest.getPreferences();
2
3String portletResource = ParamUtil.getString(request, "portletResource");
4
5if (Validator.isNotNull(portletResource)) {
6    preferences = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
7}


Hope it helps.
Rashidi Zin
RE: Portlet's Look and Feel Overwrites Configuration
9 septembre 2013 18:11
Réponse

Rashidi Zin

Rang: New Member

Publications: 3

Date d'inscription: 14 juin 2013

Publications Récentes

Hi Kan Zhang. Thank you for your reply.

The issue has been fixed. You are right. I am using AJAX and sorry for not mentioning it in my question. I didn't think that it was relevant. I am using the method you suggested.

However that is not the problem. The error occurred due to Liferay generating the wrong target URL. When I choose 'Link Portlet URLs to Page', I wanted the target page to be displaying information regarding the selected link. But not to perform AJAX operation.

I'm using resourceURL to generate the url for AJAX called:

1<portlet:resourceURL var="ajaxResourceURL" />


With this Liferay generated the URL pointing to the target URL while what I need the current site itself. Hence when I made another AJAX called it is the target page being called and that page does not have any configurations being assigned to. Thus the error occurred.

My solution is replacing the target URL's path (ajaxResourceURL) with the current path using javascript.

1var url = '<%= ajaxResourceURL %>';
2var path = url.substring(url.lastIndexOf("/") + 1, url.indexOf("?"));
3var pathname = window.location.pathname;
4
5pathname = pathname.substring(pathname.lastIndexOf("/") + 1, pathname.length);
6url = url.replace(path, pathname);


Hopefuly this will help others who face the same problem in future emoticon