Forums de discussion

[Solved] Custom Porlet Parameters per Portlet Instance?

thumbnail
yaragad from Spain, modifié il y a 12 années.

[Solved] Custom Porlet Parameters per Portlet Instance?

Junior Member Publications: 52 Date d'inscription: 15/03/11 Publications récentes
I have a portlet to connect to a DB. This portlet will be places in differente places of the portal.

- The difference between them is one parameter (the IP conection).
- For a given moment, it should be possible to change the IP of a Portlet intance.


Is possible something like this?

thumbnail
Raja Nagendra Kumar, modifié il y a 12 années.

RE: Custom Porlet Parameters per Portlet Instance?

Expert Publications: 484 Date d'inscription: 02/03/06 Publications récentes
Yes, this is possible with your portlet having edit mode with instance configurable property ip.

Read more on Edit Mode of portlets or portlet preferences.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
thumbnail
yaragad from Spain, modifié il y a 12 années.

RE: Custom Porlet Parameters per Portlet Instance?

Junior Member Publications: 52 Date d'inscription: 15/03/11 Publications récentes
Ok, thanks. The full solution is here and it works. But, how can I get the saved value in the input texbox to see the current value?

http://www.liferay.com/es/community/wiki/-/wiki/Main/How+to+Add+Configuration+Page+to+a+Plugin+Portlet

What I mean is:

<input type="text" name="<portlet:namespace />description" size="25" value="I want the current value here">
thumbnail
yaragad from Spain, modifié il y a 12 années.

RE: Custom Porlet Parameters per Portlet Instance?

Junior Member Publications: 52 Date d'inscription: 15/03/11 Publications récentes
Ok, done

PortletPreferences preferences = renderRequest.getPreferences();
		String portletResource = ParamUtil.getString(renderRequest, "portletResource");
		if (Validator.isNotNull(portletResource)) {
			preferences = PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portletResource);
		}
		String testField = preferences.getValue("testField", StringPool.BLANK);
		renderRequest.setAttribute("testFieldAt", testField);


And in the JSP file:

   <input label="Label name" name="testField" value="${testFieldAt}">