Author: mwringe
Date: 2010-02-11 18:18:32 -0500 (Thu, 11 Feb 2010)
New Revision: 1650
Added:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/GrowingOutputStream.java
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplicationChildren.gtmpl
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
Log:
Add support for portlet html markup headers. Requires changes to how the
UIPortalApplication is configured to be rendered in order to render in the correct
sequence.
Added:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/GrowingOutputStream.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/GrowingOutputStream.java
(rev 0)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/GrowingOutputStream.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -0,0 +1,81 @@
+package org.exoplatform.commons.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class GrowingOutputStream extends OutputStream{
+
+ private final OutputStream out;
+
+ private ByteArrayOutputStream buffer;
+
+ private boolean open;
+
+ public GrowingOutputStream(OutputStream out, int initialBufferSize) {
+ if (out == null)
+ {
+ throw new NullPointerException("No null output stream");
+ }
+ if (initialBufferSize < 0)
+ {
+ throw new IllegalArgumentException("No initial buffer size under
0");
+ }
+
+ this.out = out;
+ this.buffer = new ByteArrayOutputStream(initialBufferSize);
+ this.open = true;
+ }
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ if (!open)
+ {
+ throw new IOException("closed");
+ }
+ buffer.write(b);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException
+ {
+ if (!open)
+ {
+ throw new IOException("closed");
+ }
+ buffer.write(b, off, len);
+ }
+
+ @Override
+ public void flush() throws IOException
+ {
+ if (!open)
+ {
+ throw new IOException("closed");
+ }
+
+ //
+ out.write(buffer.toByteArray());
+
+ //
+ out.flush();
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ if (!open)
+ {
+ throw new IOException("closed");
+ }
+
+ //
+ out.write(buffer.toByteArray());
+
+ //
+ open = false;
+ out.close();
+ }
+
+}
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/OutputStreamPrinter.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -77,7 +77,7 @@
*/
public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean
flushOnClose) throws IllegalArgumentException
{
- this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, 0);
+ this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, 0, false);
}
/**
@@ -92,7 +92,7 @@
*/
public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean
flushOnClose, int bufferSize) throws IllegalArgumentException
{
- this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, bufferSize);
+ this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, bufferSize, false);
}
/**
@@ -101,11 +101,27 @@
*
* @param encoder the encoder
* @param out the output
+ * @param flushOnClose flush when stream is closed
+ * @param bufferSize the initial size of the buffer
+ * @param growing if the buffer should grow in size once full
* @throws IllegalArgumentException if any argument is null
*/
+ public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean
flushOnClose, int bufferSize, boolean growing) throws IllegalArgumentException
+ {
+ this(encoder, out, IOFailureFlow.RETHROW, false, flushOnClose, bufferSize,
growing);
+ }
+
+ /**
+ * Builds an instance with the failureFlow being {@link IOFailureFlow#RETHROW} and
+ * a the ignoreOnFailure property set to false.
+ *
+ * @param encoder the encoder
+ * @param out the output
+ * @throws IllegalArgumentException if any argument is null
+ */
public OutputStreamPrinter(TextEncoder encoder, OutputStream out) throws
IllegalArgumentException
{
- this(encoder, out, IOFailureFlow.RETHROW, false, false, 0);
+ this(encoder, out, IOFailureFlow.RETHROW, false, false, 0, false);
}
/**
@@ -120,12 +136,27 @@
* @throws IllegalArgumentException if any argument is null
*/
public OutputStreamPrinter(
+ TextEncoder encoder,
+ OutputStream out,
+ IOFailureFlow failureFlow,
+ boolean ignoreOnFailure,
+ boolean flushOnClose,
+ int bufferSize)
+ throws IllegalArgumentException
+ {
+ this(encoder, out, failureFlow, ignoreOnFailure, flushOnClose, bufferSize, false);
+ }
+
+
+ public OutputStreamPrinter(
TextEncoder encoder,
OutputStream out,
IOFailureFlow failureFlow,
boolean ignoreOnFailure,
boolean flushOnClose,
- int bufferSize)
+ int bufferSize,
+ boolean growing
+ )
throws IllegalArgumentException
{
if (encoder == null)
@@ -146,10 +177,14 @@
}
//
- if (bufferSize > 0)
+ if (bufferSize > 0 && !growing)
{
out = new BufferingOutputStream(out, bufferSize);
}
+ else if (growing)
+ {
+ out = new GrowingOutputStream(out, bufferSize);
+ }
//
this.encoder = encoder;
@@ -365,4 +400,13 @@
throw e;
}
}
+
+ /**
+ * Flush the output stream. This allows for the outputstream
+ * to be independently flushed regardless of the flushOnClose setting.
+ */
+ public void flushOutputStream() throws IOException
+ {
+ out.flush();
+ }
}
Modified:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java
===================================================================
---
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/PortalPrinter.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -37,4 +37,9 @@
{
super(encoder, out, flushOnClose, bufferSize);
}
+
+ public PortalPrinter(OutputStream out, boolean flushOnClose, int bufferSize, boolean
growing) throws IllegalArgumentException
+ {
+ super(encoder, out, flushOnClose, bufferSize, growing);
+ }
}
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-02-11
23:18:32 UTC (rev 1650)
@@ -1,141 +1,144 @@
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<%
- import org.exoplatform.portal.application.PortalRequestContext ;
- import org.exoplatform.webui.core.UIComponent;
- import java.util.Iterator;
- import org.exoplatform.portal.webui.portal.UIPortal ;
- import org.exoplatform.portal.config.model.PortalProperties ;
-
- def rcontext = _ctx.getRequestContext() ;
- String docBase = rcontext.getRequestContextPath() ;
- String skin = uicomponent.getSkin();
- def portalSkins = uicomponent.getPortalSkins() ;
- def portletSkins = uicomponent.getPortletSkins() ;
- def scriptsPaths = uicomponent.getJavascriptURLs();
- def lang = uicomponent.getLocale().getLanguage();
- def title = rcontext.getTitle();
- def metaInformation = rcontext.getMetaInformation();
-%>
-
-<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="$lang"
lang="$lang" dir="$dir">
- <head id="head">
- <title><%=title%></title>
- <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"/>
- <%
- if(metaInformation!= null) {
- Iterator<String> keys = metaInformation.keySet().iterator();
- while(keys.hasNext()) {
- String metaName = keys.next();
- String metaContent = metaInformation.get(metaName);
- %>
- <meta name="<%=metaName%>"
content="<%=metaContent%>" />
- <% } } %>
-
- <link rel="shortcut icon" type="image/x-icon"
href="<%=docBase%>/favicon.ico" />
- <%for(skinConfig in portalSkins) {
- def url = skinConfig.createURL();
- url.setOrientation(orientation);
- %>
- <link id="${skinConfig.id}" rel="stylesheet"
type="text/css" href="$url" />
- <%}%>
- <%for(portletSkin in portletSkins) {
- def url = portletSkin.createURL();
- url.setOrientation(orientation);
- %>
- <link id="${portletSkin.id}" rel="stylesheet"
type="text/css" href= "$url" />
- <%}%>
- <script type="text/javascript">
- // This variable must be used only to initialize other variables otherwise
- // please use eXo.env.portal.context or eXo.env.portal.context instead
- // Those 2 last variables cannot be used to initialize variables because
- // we cannot be sure that they will be initialized before initializing your script
- var currentContext = '<%=docBase%>' ;
- </script>
- <%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
- for(path in scriptsPaths) { %>
- <script type="text/javascript"
src="<%=path%>"></script>
- <% }
- } else {
- %>
- <script type="text/javascript"
src="<%=docBase%>/javascript/merged.js"></script>
- <%}%>
- <script type="text/javascript">
- eXo.env.portal.context = '<%=docBase%>' ;
- <%if(rcontext.getAccessPath() == 0) {%>
- eXo.env.portal.accessMode = 'public' ;
- <%} else {%>
- eXo.env.portal.accessMode = 'private' ;
- <%}%>
- eXo.env.portal.portalName = '<%=rcontext.getPortalOwner()%>' ;
- eXo.env.server.context = '<%=docBase%>' ;
- eXo.env.server.portalBaseURL =
'<%=rcontext.getURLBuilder().getBaseURL()%>' ;
- eXo.env.client.skin = '$skin' ;
- <%
- UIPortal portal = uicomponent.findFirstComponentOfType(UIPortal.class);
- String sessionAliveLevel = (portal == null ? null : portal.sessionAlive) ;
- boolean canKeepState = sessionAliveLevel == null ? false :
!sessionAliveLevel.equals(PortalProperties.SESSION_NEVER) ;
- %>
-
- eXo.portal.portalMode = <%= uicomponent.getModeState() %>;
-
- eXo.session.level = '$sessionAliveLevel';
- eXo.session.canKeepState = $canKeepState;
- eXo.session.isOpen = $uicomponent.isSessionOpen ;
- eXo.session.itvTime =
${((PortalRequestContext)rcontext).getRequest().getSession().getMaxInactiveInterval()} ;
- </script>
- <script type="text/javascript"
src="/eXoResources/javascript/eXo/i18n/I18NMessage.js"></script>
- <script type="text/javascript"
src="/eXoResources/javascript/eXo/i18n/MessageResource_<%=lang%>.js"></script>
- </head>
-
- <body style="height: 100%;">
- <%
- /*Hide All Popup Menu when click on document*/
-
rcontext.getJavascriptManager().addOnLoadJavascript('eXo.core.DOMUtil.hideElements');
-
//rcontext.getJavascriptManager().addOnResizeJavascript('eXo.core.UIMaskLayer.resizeMaskLayer');
- %>
-
- <div class="$uicomponent.skin" id="UIPortalApplication"
style="!height: 100%;">
-
- <div class="AjaxLoadingMask" id="AjaxLoadingMask"
style="display: none; margin: auto;">
- <div class="LoadingContainer">
- <div class="CenterLoadingContainer">
- <div
class="LoadingText"><%=_ctx.appRes("UIPortalApplication.label.Loading")%></div>
- <div
class="LoadingProgressBar"><span></span></div>
-
- <div class="UIAction">
- <table class="ActionContainer">
- <tr>
- <td>
- <div onclick="javascript:ajaxAbort();" class="ActionButton
LightBlueStyle">
- <div class="ButtonLeft">
- <div class="ButtonRight">
- <div class="ButtonMiddle">
- <a
href="javascript:void(0);"><%=_ctx.appRes("UIPortalApplication.label.Abort")%></a>
- </div>
- </div>
- </div>
- </div>
- </td>
- </tr>
- </table>
- </div>
-
- </div>
- </div>
- </div>
-
- <%uicomponent.renderChildren();%>
- </div>
-
-
-
- <script type="text/javascript">
- <%=rcontext.getJavascriptManager().getJavascript()%>
- eXo.core.Browser.onLoad();
- <%=rcontext.getJavascriptManager().getCustomizedOnLoadScript();%>
- <%if(canKeepState && uicomponent.isSessionOpen) {%>
eXo.session.itvInit() ;<%}%>
- </script>
- </body>
-</html>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%
+ import org.exoplatform.portal.application.PortalRequestContext ;
+ import org.exoplatform.webui.core.UIComponent;
+ import java.util.Iterator;
+ import org.exoplatform.portal.webui.portal.UIPortal ;
+ import org.exoplatform.portal.config.model.PortalProperties ;
+
+ def rcontext = _ctx.getRequestContext() ;
+ String docBase = rcontext.getRequestContextPath() ;
+ String skin = uicomponent.getSkin();
+ def portalSkins = uicomponent.getPortalSkins() ;
+ def portletSkins = uicomponent.getPortletSkins() ;
+ def scriptsPaths = uicomponent.getJavascriptURLs();
+ def lang = uicomponent.getLocale().getLanguage();
+ def title = rcontext.getTitle();
+ def metaInformation = rcontext.getMetaInformation();
+%>
+
+<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="$lang"
lang="$lang" dir="$dir">
+ <head id="head">
+ <title><%=title%></title>
+ <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"/>
+ <%
+ if(metaInformation!= null) {
+ Iterator<String> keys = metaInformation.keySet().iterator();
+ while(keys.hasNext()) {
+ String metaName = keys.next();
+ String metaContent = metaInformation.get(metaName);
+ %>
+ <meta name="<%=metaName%>"
content="<%=metaContent%>" />
+ <% } } %>
+
+ <link rel="shortcut icon" type="image/x-icon"
href="<%=docBase%>/favicon.ico" />
+ <%for(skinConfig in portalSkins) {
+ def url = skinConfig.createURL();
+ url.setOrientation(orientation);
+ %>
+ <link id="${skinConfig.id}" rel="stylesheet"
type="text/css" href="$url" />
+ <%}%>
+ <%for(portletSkin in portletSkins) {
+ def url = portletSkin.createURL();
+ url.setOrientation(orientation);
+ %>
+ <link id="${portletSkin.id}" rel="stylesheet"
type="text/css" href= "$url" />
+ <%}%>
+ <script type="text/javascript">
+ // This variable must be used only to initialize other variables otherwise
+ // please use eXo.env.portal.context or eXo.env.portal.context instead
+ // Those 2 last variables cannot be used to initialize variables because
+ // we cannot be sure that they will be initialized before initializing your script
+ var currentContext = '<%=docBase%>' ;
+ </script>
+ <%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
+ for(path in scriptsPaths) { %>
+ <script type="text/javascript"
src="<%=path%>"></script>
+ <% }
+ } else {
+ %>
+ <script type="text/javascript"
src="<%=docBase%>/javascript/merged.js"></script>
+ <%}%>
+ <script type="text/javascript">
+ eXo.env.portal.context = '<%=docBase%>' ;
+ <%if(rcontext.getAccessPath() == 0) {%>
+ eXo.env.portal.accessMode = 'public' ;
+ <%} else {%>
+ eXo.env.portal.accessMode = 'private' ;
+ <%}%>
+ eXo.env.portal.portalName = '<%=rcontext.getPortalOwner()%>' ;
+ eXo.env.server.context = '<%=docBase%>' ;
+ eXo.env.server.portalBaseURL =
'<%=rcontext.getURLBuilder().getBaseURL()%>' ;
+ eXo.env.client.skin = '$skin' ;
+ <%
+ UIPortal portal = uicomponent.findFirstComponentOfType(UIPortal.class);
+ String sessionAliveLevel = (portal == null ? null : portal.sessionAlive) ;
+ boolean canKeepState = sessionAliveLevel == null ? false :
!sessionAliveLevel.equals(PortalProperties.SESSION_NEVER) ;
+ %>
+
+ eXo.portal.portalMode = <%= uicomponent.getModeState() %>;
+
+ eXo.session.level = '$sessionAliveLevel';
+ eXo.session.canKeepState = $canKeepState;
+ eXo.session.isOpen = $uicomponent.isSessionOpen ;
+ eXo.session.itvTime =
${((PortalRequestContext)rcontext).getRequest().getSession().getMaxInactiveInterval()} ;
+ </script>
+ <script type="text/javascript"
src="/eXoResources/javascript/eXo/i18n/I18NMessage.js"></script>
+ <script type="text/javascript"
src="/eXoResources/javascript/eXo/i18n/MessageResource_<%=lang%>.js"></script>
+
+ <%
+ def headerElements = rcontext.getExtraMarkupHeaders();
+ if (headerElements != null)
+ {
+ for (element in headerElements)
+ { %>
+ <%=element%>
+ <% }
+ }
+ %>
+ </head>
+
+ <body style="height: 100%;">
+ <%
+ /*Hide All Popup Menu when click on document*/
+
rcontext.getJavascriptManager().addOnLoadJavascript('eXo.core.DOMUtil.hideElements');
+
//rcontext.getJavascriptManager().addOnResizeJavascript('eXo.core.UIMaskLayer.resizeMaskLayer');
+ %>
+ <script type="text/javascript">
+ <%=rcontext.getJavascriptManager().getJavascript()%>
+ eXo.core.Browser.onLoad();
+ <%=rcontext.getJavascriptManager().getCustomizedOnLoadScript();%>
+ <%if(canKeepState && uicomponent.isSessionOpen) {%>
eXo.session.itvInit() ;<%}%>
+ </script>
+
+ <div class="$uicomponent.skin" id="UIPortalApplication"
style="!height: 100%;">
+
+ <div class="AjaxLoadingMask" id="AjaxLoadingMask"
style="display: none; margin: auto;">
+ <div class="LoadingContainer">
+ <div class="CenterLoadingContainer">
+ <div
class="LoadingText"><%=_ctx.appRes("UIPortalApplication.label.Loading")%></div>
+ <div
class="LoadingProgressBar"><span></span></div>
+
+ <div class="UIAction">
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div onclick="javascript:ajaxAbort();" class="ActionButton
LightBlueStyle">
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <a
href="javascript:void(0);"><%=_ctx.appRes("UIPortalApplication.label.Abort")%></a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ </div>
+ </div>
+ </div>
Added:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplicationChildren.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplicationChildren.gtmpl
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplicationChildren.gtmpl 2010-02-11
23:18:32 UTC (rev 1650)
@@ -0,0 +1,4 @@
+ <%uicomponent.renderChildren();%>
+ </div>
+ </body>
+</html>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -38,6 +38,7 @@
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.lifecycle.HtmlValidator;
+import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -45,8 +46,10 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URLDecoder;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -99,6 +102,8 @@
protected JavascriptManager jsmanager_ = new JavascriptManager();
+ private List<Element> extraMarkupHeaders;
+
private final PortalURLBuilder urlBuilder;
public JavascriptManager getJavascriptManager()
@@ -301,6 +306,11 @@
}
return writer_;
}
+
+ final public void setWriter(Writer writer)
+ {
+ this.writer_ = writer;
+ }
final public boolean useAjax()
{
@@ -344,5 +354,28 @@
response_.setHeader(key, headers.get(key));
}
}
+
+ /**
+ * Get the extra markup headers to add to the head of the html.
+ * @return The markup to be added.
+ */
+ public List<Element> getExtraMarkupHeaders()
+ {
+ return this.extraMarkupHeaders;
+ }
+
+ /**
+ * Add an extra markup to the head of the html page.
+ * @param element The element to add
+ */
+ public void addExtraMarkupHeader(Element element)
+ {
+ if (this.extraMarkupHeaders == null)
+ {
+ this.extraMarkupHeaders = new ArrayList<Element>();
+ }
+ this.extraMarkupHeaders.add(element);
+ }
+
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -646,6 +646,7 @@
HashMap<String, String[]> allParams = new HashMap<String, String[]>();
allParams.putAll(servletRequest.getParameterMap());
allParams.putAll(this.getPublicParameters());
+ //allParams.remove(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
if (type.equals(ActionInvocation.class))
{
ActionInvocation actionInvocation = new ActionInvocation(pic);
@@ -758,7 +759,7 @@
invocation.setUserContext(new ExoUserContext(servletRequest, userProfile));
invocation.setWindowContext(new ExoWindowContext(storageName));
invocation.setPortalContext(new AbstractPortalContext(Collections.singletonMap(
- "javax.portlet.markup.head.element.support", "false")));
+ "javax.portlet.markup.head.element.support", "true")));
invocation.setSecurityContext(new AbstractSecurityContext(servletRequest));
//
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -43,11 +43,14 @@
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.FragmentResponse;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.w3c.dom.Element;
import java.io.Serializable;
import java.nio.charset.Charset;
+import java.util.List;
import java.util.Map;
+import javax.portlet.MimeResponse;
import javax.portlet.PortletMode;
import javax.portlet.WindowState;
@@ -227,6 +230,30 @@
}
}
}
+
+ //setup markup headers
+ if (fragmentResponse.getProperties().getMarkupHeaders() != null)
+ {
+ MultiValuedPropertyMap<Element> markupHeaders =
+ fragmentResponse.getProperties().getMarkupHeaders();
+
+ List<Element> markupElements =
markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
+ if (markupElements != null)
+ {
+ for (Element element : markupElements)
+ {
+ if ("title".equals(element.getNodeName().toLowerCase())
&& element.getFirstChild() != null)
+ {
+ String title = element.getFirstChild().getTextContent();
+
prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
+ }
+ else
+ {
+ prcontext.addExtraMarkupHeader(element);
+ }
+ }
+ }
+ }
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-02-11
21:32:06 UTC (rev 1649)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-02-11
23:18:32 UTC (rev 1650)
@@ -19,9 +19,17 @@
package org.exoplatform.portal.webui.workspace;
+import java.io.CharArrayWriter;
+import java.io.OutputStream;
+import java.io.Writer;
+
+import org.exoplatform.commons.utils.PortalPrinter;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.resolver.ResourceResolver;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.lifecycle.Lifecycle;
+import org.exoplatform.webui.core.lifecycle.WebuiBindingContext;
/**
* Created by The eXo Platform SAS
@@ -65,5 +73,52 @@
super.processAction(uicomponent, context);
uiTarget.processAction(context);
}
+
+ public void processRender(UIPortalApplication uicomponent,
+ WebuiRequestContext context) throws Exception
+ {
+ /* We need to render the child elements of the portal first since portlets can set the
markup headers
+ * during there render call.
+ * We cannot render the page in the order of the UIPortalApplication since this will
create the headers
+ * before the portlets are rendered. To get around this we need to render the portlets
and UIPortalApplication
+ * childrens to a separate writer first, then render the UIPortalApplication page as
normal, outputting
+ * the contents of the separate writer where the child elements should be rendered.
+ * Its messy but required for portlet markup header setting.
+ */
+
+ PortalRequestContext prc = (PortalRequestContext) context;
+ OutputStream responseOutputStream = prc.getResponse().getOutputStream();
+
+ PortalPrinter parentWriter = new PortalPrinter(responseOutputStream, true, 5000);
+ PortalPrinter childWriter = new PortalPrinter(responseOutputStream, true, 25000,
true);
+
+ context.setWriter(childWriter);
+ processRender(uicomponent, context,
"system:/groovy/portal/webui/workspace/UIPortalApplicationChildren.gtmpl");
+ context.setWriter(parentWriter);
+ processRender(uicomponent, context,
"system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl");
+
+ //flush the parent writer to the output stream so that we are really to accept the
child content
+ parentWriter.flushOutputStream();
+ //now that the parent has been flushed, we can flush the contents of the child to the
output
+ childWriter.flushOutputStream();
+ }
+
+ public void processRender(UIPortalApplication uicomponent, WebuiRequestContext context,
String template) throws Exception
+ {
+ // Fail if we have no template
+ if (template == null)
+ {
+ throw new IllegalStateException("uicomponent " + uicomponent + "
with class " + uicomponent.getClass().getName() +
+ " has no template for rendering");
+ }
+
+ //
+ ResourceResolver resolver = uicomponent.getTemplateResourceResolver(context,
template);
+ WebuiBindingContext bcontext = new WebuiBindingContext(resolver,
context.getWriter(), uicomponent, context);
+ bcontext.put(UIComponent.UICOMPONENT, uicomponent);
+ bcontext.put(uicomponent.getUIComponentName(), uicomponent);
+ renderTemplate(template, bcontext);
+ }
+
}
\ No newline at end of file