Forums de discussion

mutablePortletPreferencesValues problem?

Witold Wolski, modifié il y a 11 années.

mutablePortletPreferencesValues problem?

New Member Publications: 20 Date d'inscription: 06/02/12 Publications récentes
Hallo,

I am working with the example
http://www.portletfaces.org/doc/portletfaces-bridge/2.0.0/docbook/en-US/html/portletpreferences-and-jsf.html

In the portlet.xml I defined 2 portlet preferences
<portlet-preferences>
<preference>
<name>displaytext</name>
<value>Hello, from your preferences</value>
</preference>
<preference>
<name>bla</name>
<value>Hello, from your preferences</value>
</preference>
</portlet-preferences>

And I am trying to access them using the following code:

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
String elExpression = "mutablePortletPreferencesValues";
ELResolver elResolver = facesContext.getApplication().getELResolver();
@SuppressWarnings("unchecked")
Map<String, Preference> mutablePreferenceMap = (Map<String, Preference>) elResolver
.getValue(facesContext.getELContext(), null, elExpression);

Unfortunately the returned mutablePreferenceMap has size 0.

Thanks in advance
Witold
thumbnail
Neil Griffin, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
The PortletPreferencesBackingBean.java class in the jsf2-portlet demo has a working example.
Witold Wolski, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

New Member Publications: 20 Date d'inscription: 06/02/12 Publications récentes
Is the xhtml example supposed to work?

<td><h:inputText id="datePattern" value="#{mutablePortletPreferencesValues['datePattern'].value}" /></td>

Because I can't get it running. Is a workaround required?

Thank you.
thumbnail
Neil Griffin, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
When you get a chance, please download and deploy the jsf2-portlet and let me know if it doesn't work. It passed QA testing last week before the release of RC1.
Witold Wolski, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

New Member Publications: 20 Date d'inscription: 06/02/12 Publications récentes
Hi Neil

Installed the example porltet jsf2-portlet installed and running.
The mutablePortletPreferencesValues['datePattern'].value returns the date format as supposed.


So now I am really wondering/confused/depressed. Why in case of my portlet the same code isn't working?
Seems that I have the same jar's (created the portlet a few weeks back based on an example portlet)

-rw-r--r--  1 wolski  staff   163119 May 14 15:23 alloyfaces-1.0.1.0.jar
-rw-r--r--  1 wolski  staff   211157 May 14 15:23 icefaces-2.0.2.jar
-rw-r--r--  1 wolski  staff  2798929 May 14 15:23 icefaces-compat-2.0.2.jar
-rw-r--r--  1 wolski  staff   133966 May 14 15:23 jboss-el-2.0.0.GA.jar
-rw-r--r--  1 wolski  staff   626231 May 10 16:33 jsf-api-2.1.3-b02.jar
-rw-r--r--  1 wolski  staff  1936496 May 10 16:33 jsf-impl-2.1.3-b02.jar
-rw-r--r--  1 wolski  staff   393636 May 10 16:33 liferay-faces-bridge-impl-3.0.0-BETA2.jar
-rw-r--r--  1 wolski  staff    27184 May 10 16:33 portlet-bridge-api-2.0.0.jar

My portlet.xml looks like this:

<!--?xml version="1.0"?-->
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
	<portlet>
		<portlet-name>BioDB</portlet-name>
		<display-name>BioDB</display-name>
		<portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.view</name>
			<value>/xhtml/portletViewMode.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.edit</name>
			<value>/xhtml/edit.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.help</name>
			<value>/xhtml/help.xhtml</value>
		</init-param>
		<supports>
			<mime-type>text/html</mime-type>
			<portlet-mode>view</portlet-mode>
			<portlet-mode>edit</portlet-mode>
			<portlet-mode>help</portlet-mode>
		</supports>
		<portlet-info>
			<title>BioDB</title>
			<short-title>BioDB</short-title>
			<keywords>BioDB</keywords>
		</portlet-info>
		<portlet-preferences>
			<preference>
				<name>datePattern</name>
				<value>MM/dd/yyyy</value>
			</preference>
			<preference>
				<name>recipientEmailAddress</name>
				<value>humanresources@some-company-domain.com</value>
			</preference>
		</portlet-preferences>
		<supported-publishing-event>
			<qname xmlns:x="http://ismb.ethz.ch/events">x:ipc.bioDB</qname>
		</supported-publishing-event>
	</portlet>
	<event-definition>
		<qname xmlns:x="http://liferay.com/events">x:ipc.bioDB</qname>
		<value-type>ch.systemsx.ethz.imsb.openbis.dto.SelectedBioDBDatabase</value-type>
	</event-definition>
</portlet-app>


and the edit.xthml like this

<!--?xml version="1.0"?-->
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc">
	<h:head />
	<h:body>
			<h:form>

		<h:messages globalOnly="true" />

		<table>
			<tbody><tr>
				<!-- <td><h:outputLabel for="datePattern"
						value="#{i18n['date-format']}" /></td> -->
				<td><h:inputtext id="datePattern" value="#{mutablePortletPreferencesValues['datePattern'].value}" /></td>
				<!-- <td><h:message for="datePattern" /></td> -->
			</tr>
		</tbody></table>

		<hr>

		<h:commandbutton actionListener="#{portletPreferencesBackingBean.submit}" value="#{i18n['submit']}" />
		<h:commandbutton actionListener="#{portletPreferencesBackingBean.reset}" value="#{i18n['reset']}" />

	</h:form>
	</h:body>
</f:view>


Nevertheless, in case of my portlet no datePattern value is displayed.
What other sources can cause the diffence in the behaviour?

Regards
Witold
thumbnail
Neil Griffin, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
The only thing that I can think of regarding this, is that there is a quirk/bug in Liferay Portal such that, after a portlet has been added to a portal page, subsequent changes to <portlet-preferences> values in WEB-INF/portlet.xml do not get reflected in the Liferay database table.

So I would recommend that you try the following steps:

1. Create a new portal page
2. Add your portlet to the new portal page
3. Try your preference use-case again
J S, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

Junior Member Publications: 31 Date d'inscription: 11/04/12 Publications récentes
Is that a quirk or a bug?

John
thumbnail
Neil Griffin, modifié il y a 11 années.

RE: mutablePortletPreferencesValues problem?

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
This is a limitation that has been a part of the portal's design for many years. It's really an issue that should only be encountered in development. I suppose that it could also happen after portlet updates to production servers too, but would be less likely. I did a quick search of the Liferay Issue Tracker but didn't see this reported yet as a bug. If you want you can always create an LPS issue.