<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>PortletDemoPortlet</portlet-name>
<display-name>Vaadin PortletDemo</display-name>
<short-title>HelloWorld</short-title>
</portlet-info>
</portlet>
-
- <!--
+
+ <!--
<portlet>
<portlet-name>VaadinInterPortletEventPortlet</portlet-name>
<display-name>Hello World Event</display-name>
<portlet-info>
<title>Inter-portlet events</title>
<short-title>Inter-portlet events</short-title>
- </portlet-info>
+ </portlet-info>
<supported-processing-event>
<qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname>
</supported-processing-event>
<supported-publishing-event>
<qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname>
</supported-publishing-event>
+ <supported-public-render-parameter>HelloState</supported-public-render-parameter>
</portlet>
<portlet>
<supported-publishing-event>
<qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname>
</supported-publishing-event>
+ <supported-public-render-parameter>HelloState</supported-public-render-parameter>
</portlet>
-->
</security-role-ref>
</portlet>
+ <!--
+ These can be used to customize the event object types.
+ The types must be serializable and have JAXB binding.
+ -->
<event-definition>
<qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname>
<value-type>java.lang.String</value-type>
<value-type>java.lang.String</value-type>
</event-definition>
+ <public-render-parameter>
+ <identifier>HelloState</identifier>
+ <qname xmlns:vaadin="http://www.vaadin.com/params">vaadin:HelloState</qname>
+ </public-render-parameter>
+
<!--
This can be used to work around an issue in liferay 5.0-5.1.1
private Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>();
private Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>();
+ private Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>();
+ private Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>();
+
public File getBaseDirectory() {
String resultPath = session.getPortletContext().getRealPath("/");
if (resultPath != null) {
// cleanup
eventActionDestinationMap.remove(key);
eventActionValueMap.remove(key);
+ } else if (sharedParameterActionNameMap.containsKey(key)) {
+ // this action request is only to set shared render parameters
+ response.setRenderParameter(sharedParameterActionNameMap.get(key),
+ sharedParameterActionValueMap.get(key));
+ // cleanup
+ sharedParameterActionNameMap.remove(key);
+ sharedParameterActionValueMap.remove(key);
} else {
+ // normal action request, notify listeners
Set<PortletListener> listeners = portletListeners.get(app);
if (listeners != null) {
for (PortletListener l : listeners) {
/**
* Sends a portlet event to the indicated destination.
- *
+ *
* Internally, an action may be created and opened, as an event cannot be
* sent directly from all types of requests.
- *
+ *
* The event destinations and values need to be kept in the context until
* sent. Any memory leaks if the action fails are limited to the session.
- *
+ *
* Event names for events sent and received by a portlet need to be declared
* in portlet.xml .
- *
+ *
* @param window
* a window in which a temporary action URL can be opened if
* necessary
"Portlet events can only be sent from a portlet request");
}
}
+
+ /**
+ * Sets a shared portlet parameter.
+ *
+ * Internally, an action may be created and opened, as shared parameters
+ * cannot be set directly from all types of requests.
+ *
+ * The parameters and values need to be kept in the context until sent. Any
+ * memory leaks if the action fails are limited to the session.
+ *
+ * Shared parameters set or read by a portlet need to be declared in
+ * portlet.xml .
+ *
+ * @param window
+ * a window in which a temporary action URL can be opened if
+ * necessary
+ * @param name
+ * parameter identifier
+ * @param value
+ * parameter value
+ */
+ public void setSharedRenderParameter(Window window, String name,
+ String value) throws IllegalStateException {
+ if (response instanceof MimeResponse) {
+ String actionKey = "" + System.currentTimeMillis();
+ while (sharedParameterActionNameMap.containsKey(actionKey)) {
+ actionKey = actionKey + ".";
+ }
+ PortletURL actionUrl = generateActionURL(actionKey);
+ if (actionUrl != null) {
+ sharedParameterActionNameMap.put(actionKey, name);
+ sharedParameterActionValueMap.put(actionKey, value);
+ window.open(new ExternalResource(actionUrl.toString()));
+ } else {
+ // this should never happen as we already know the response is a
+ // MimeResponse
+ throw new IllegalStateException(
+ "Shared parameters can only be set from a portlet request");
+ }
+ } else if (response instanceof StateAwareResponse) {
+ ((StateAwareResponse) response).setRenderParameter(name, value);
+ } else {
+ throw new IllegalStateException(
+ "Shared parameters can only be set from a portlet request");
+ }
+ }
}