cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r157737 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal: conf/portal.samplesxconf java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java
Date Wed, 16 Mar 2005 11:52:36 GMT
Author: cziegeler
Date: Wed Mar 16 03:52:32 2005
New Revision: 157737

URL: http://svn.apache.org/viewcvs?view=rev&rev=157737
Log:
Fix bug in content generation for no-window coplets: content element is not generated anymore

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf?view=diff&r1=157736&r2=157737
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf Wed Mar 16 03:52:32
2005
@@ -144,7 +144,9 @@
      <renderer name="nowindow" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer"
logger="portal">
          <aspects>
              <aspect type="history"/>
-             <aspect type="coplet"/>
+             <aspect type="coplet-cinclude">
+                <parameter name="root-tag" value="false"/>
+             </aspect>
          </aspects>
      </renderer>
      <renderer name="portlet-window"

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java?view=diff&r1=157736&r2=157737
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CIncludeCopletAspect.java
Wed Mar 16 03:52:32 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.portal.layout.renderer.aspect.impl;
 
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.layout.Layout;
@@ -36,16 +38,26 @@
  * </pre>
  * where <code>xy</code> is the CInclude namespace and <code>z</code>
is
  * the CInclude tagname.
+ * By default, the cinclude statetement is surrounded by a "content" element;
+ * this can be further controlled by parameters (see below).
  * 
  * <h2>Applicable to:</h2>
  * <ul>
  *  <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
  * </ul>
  *
+ * <h2>Parameters</h2>
+ * <table><tbody>
+ *   <tr><th>root-tag</th><td>Should a tag enclosing the cinclude
be generated? (Default is true)</td>
+ *      <td></td><td>boolean</td><td><code>true</code></td></tr>
+ *   <tr><th>tag-name</th><td>Name of enclosing tag.</td>
+ *      <td></td><td>String</td><td><code>"content"</code></td></tr>
+ * </tbody></table>
+ * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * 
- * @version CVS $Id: CIncludeCopletAspect.java,v 1.6 2004/04/28 13:58:16 cziegeler Exp $
+ * @version CVS $Id$
  */
 public class CIncludeCopletAspect 
     extends AbstractCIncludeAspect {
@@ -58,15 +70,42 @@
                 		PortalService service,
                 		ContentHandler handler)
 	throws SAXException {
-        CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
-        
-        XMLUtils.startElement(handler, "content");
+        final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
+        final CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
+
+        if ( config.rootTag ) {
+            XMLUtils.startElement(handler, config.tagName);
+        }
 
         this.createCInclude("coplet://" + cid.getId(), handler);
 
-        XMLUtils.endElement(handler, "content");
-        
+        if ( config.rootTag ) {
+            XMLUtils.endElement(handler, config.tagName);
+        }
+
         context.invokeNext(layout, service, handler);
 	}
 
+    protected static class PreparedConfiguration {
+
+        public String tagName;
+        public boolean rootTag;
+        
+        public void takeValues(PreparedConfiguration from) {
+            this.tagName = from.tagName;
+            this.rootTag = from.rootTag;
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#prepareConfiguration(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public Object prepareConfiguration(Parameters configuration) 
+    throws ParameterException {
+        PreparedConfiguration pc = new PreparedConfiguration();
+        pc.tagName = configuration.getParameter("tag-name", "content");
+        pc.rootTag = configuration.getParameterAsBoolean("root-tag", true);
+        return pc;
+    }
+    
 }



Mime
View raw message