Author: cziegeler
Date: Tue Jun 2 16:36:57 2009
New Revision: 781077
URL: http://svn.apache.org/viewvc?rev=781077&view=rev
Log:
Avoid duplicate writing of header.
Modified:
incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/PortletRenderResponseContextImpl.java
Modified:
incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/PortletRenderResponseContextImpl.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/PortletRenderResponseContextImpl.java?rev=781077&r1=781076&r2=781077&view=diff
==============================================================================
---
incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/PortletRenderResponseContextImpl.java
(original)
+++
incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/PortletRenderResponseContextImpl.java
Tue Jun 2 16:36:57 2009
@@ -45,16 +45,14 @@
extends PortletMimeResponseContextImpl
implements PortletRenderResponseContext {
+ private static final String REG_ATTR_WRITTEN =
PortletRenderResponseContextImpl.class.getName() + "/written/";
/** The title set by the portlet. */
private String title;
/** The next possible portlet modes set by the portlet. */
private Collection<PortletMode> portletModes;
- /** Already written out title? */
- private boolean written = false;
-
- private boolean writeTitle = false;
+ private boolean writeTitle = true;
public PortletRenderResponseContextImpl(SlingPortletContainer container,
HttpServletRequest
containerRequest,
@@ -76,9 +74,17 @@
}
}
+ private boolean written() {
+ Boolean b = (Boolean)
this.getContainerRequest().getAttribute(REG_ATTR_WRITTEN +
this.getPortletWindow().getId().getStringId());
+ if ( b == null ) {
+ b = false;
+ }
+ return b;
+ }
+
@Override
public void close() {
- if ( !written && writeTitle) {
+ if ( writeTitle && !written() ) {
try {
this.getWriter();
} catch (IOException ignore) {
@@ -131,13 +137,13 @@
}
protected void drawWindowTitle(final PrintWriter pw) {
- if ( written ) {
+ if ( !writeTitle ) {
return;
}
- written = true;
- if ( !writeTitle ) {
+ if ( written() ) {
return;
}
+ this.getContainerRequest().setAttribute(REG_ATTR_WRITTEN +
this.getPortletWindow().getId().getStringId(), Boolean.TRUE);
pw.write("<div class='portlet-header'><div class='portlet-title'
style='float:left'>");
pw.write(this.title);
pw.write("</div>");