cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting CopletSetDataAction.java
Date Tue, 09 Dec 2003 10:21:56 GMT
cziegeler    2003/12/09 02:21:56

  Modified:    src/blocks/portal/conf portal.samplesxconf actions.xmap
               src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        CopletTransformer.java
               src/blocks/portal/samples/news/content/xdocs
                        portal-intro.xml
               src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input
                        CopletModule.java
               src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        AbstractAspectalizableDescription.java
               src/blocks/portal/samples/profiles/layout portal.xml
  Added:       src/blocks/portal/conf transformers.xmap
               src/blocks/portal/samples/skins/basic/styles linktab.xsl
               src/blocks/portal/samples/skins/common/styles linktab.xsl
               src/blocks/portal/java/org/apache/cocoon/portal/acting
                        CopletSetDataAction.java
  Log:
  Adding tab demo
  
  Revision  Changes    Path
  1.8       +20 -0     cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf
  
  Index: portal.samplesxconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- portal.samplesxconf	8 Dec 2003 15:56:25 -0000	1.7
  +++ portal.samplesxconf	9 Dec 2003 10:21:56 -0000	1.8
  @@ -47,6 +47,20 @@
                </aspect>
            </aspects>
        </renderer>
  +     <renderer name="linktab" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer"
logger="portal">
  +         <aspects>
  +             <aspect type="xslt">
  +                 <parameter name="style" value="{global:skin}styles/linktab.xsl"/>
  +             </aspect>
  +             <aspect type="parameter">
  +                 <parameter name="tag-name" value="linktab-layout"/>
  +             </aspect>
  +             <aspect type="tab-content">
  +                 <parameter name="root-tag" value="false"/>
  +                 <parameter name="store" value="session"/>
  +             </aspect>
  +         </aspects>
  +     </renderer>
        <renderer name="window" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer"
logger="portal" >
            <aspects>
                <aspect type="xslt">
  @@ -112,6 +126,12 @@
                   class="org.apache.cocoon.portal.layout.impl.CompositeLayout">
               <renderers default="tab">
                   <renderer name="tab"/>
  +            </renderers>
  +        </layout>
  +        <layout name="linktab"
  +                class="org.apache.cocoon.portal.layout.impl.CompositeLayout" >
  +            <renderers default="linktab">
  +                <renderer name="linktab"/>
               </renderers>
           </layout>
           <layout name="frame" 
  
  
  
  1.3       +2 -0      cocoon-2.1/src/blocks/portal/conf/actions.xmap
  
  Index: actions.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/actions.xmap,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- actions.xmap	1 Jun 2003 15:50:18 -0000	1.2
  +++ actions.xmap	9 Dec 2003 10:21:56 -0000	1.3
  @@ -9,4 +9,6 @@
                   src="org.apache.cocoon.portal.acting.LogoutAction"/>
       <map:action name="portal-object-model"
                   src="org.apache.cocoon.portal.acting.ObjectModelAction"/>
  +    <map:action name="portal-set-data"
  +                src="org.apache.cocoon.portal.acting.CopletSetDataAction"/>
   </xmap>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/conf/transformers.xmap
  
  Index: transformers.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <xmap xpath="/sitemap/components/transformers"
        unless="transformer[@name='portal-coplet']">
  
      <map:transformer name="portal-coplet" 
                       src="org.apache.cocoon.portal.transformation.CopletTransformer" 
                       logger="sitemap.transformer.portal" />
  </xmap>
  
  
  
  1.5       +42 -4     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
  
  Index: CopletTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CopletTransformer.java	10 Jul 2003 13:17:04 -0000	1.4
  +++ CopletTransformer.java	9 Dec 2003 10:21:56 -0000	1.5
  @@ -52,13 +52,19 @@
   
   import java.io.IOException;
   
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
  +import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
  +import org.apache.cocoon.xml.AttributesImpl;
   import org.apache.commons.jxpath.JXPathContext;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
   /**
  + * This transformer offers various functions for developing pipeline based coplets.
  + * 
    * Includes coplet instance data by using JXPath expressions.
    * The transformer searches for tags &lt;coplet:coplet xmlns:coplet="http://apache.org/cocoon/portal/coplet/1.0"&gt;.
    * They must have an attribute "select" that contains a valid JXPath expression applying
to the coplet instance data.<br><br>
  @@ -74,6 +80,7 @@
    * Please see also the documentation of superclass AbstractCopletTransformer for how
    * the coplet instance data are acquired.
    *
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
    * @version CVS $Id$
    */
  @@ -97,6 +104,11 @@
   
           
       /**
  +     * The XML element name to listen for.
  +     */
  +    public static final String LINK_ELEM = "link";
  +
  +    /**
        * Creates new CopletTransformer.
        */
       public CopletTransformer() {
  @@ -123,6 +135,30 @@
                   throw new ProcessingException("Could not find value for expression "+expression);
               }
                   
  +        } else if (name.equals(LINK_ELEM)) {
  +            AttributesImpl newAttrs = new AttributesImpl();
  +            
  +            PortalService portalService = null;
  +            try {
  +                final CopletInstanceData cid = this.getCopletInstanceData();
  +                ChangeCopletInstanceAspectDataEvent event = new ChangeCopletInstanceAspectDataEvent(cid,
null, null);
  +                
  +                portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
  +                String value = portalService.getComponentManager().getLinkService().getLinkURI(event);
  +                if (value.indexOf('?') == -1) {
  +                    value = value + '?' + attr.getValue("href");
  +                } else {
  +                    value = value + '&' + attr.getValue("href");
  +                }
  +                newAttrs.addCDATAAttribute("href", value);
  +            } catch (ServiceException e) {
  +                throw new SAXException("Error getting portal service.", e);
  +            } finally {
  +                this.manager.release( portalService );
  +            }
  +            
  +            
  +            super.startElement("", "a", "a", newAttrs);
           } else {
               super.startTransformingElement(uri, name, raw, attr);
           }
  @@ -133,9 +169,11 @@
        */
       public void endTransformingElement(String uri, String name, String raw) 
       throws ProcessingException, IOException, SAXException {
  -        if (!name.equals(COPLET_ELEM)) {
  +        if ( name.equals(LINK_ELEM) ) {
  +            super.endElement("", "a", "a");
  +        } else if (!name.equals(COPLET_ELEM)) {
               super.endTransformingElement(uri, name, raw);
  -        }
  +        }  
       }
  -
  +    
   }
  
  
  
  1.2       +10 -5     cocoon-2.1/src/blocks/portal/samples/news/content/xdocs/portal-intro.xml
  
  Index: portal-intro.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/news/content/xdocs/portal-intro.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- portal-intro.xml	29 Sep 2003 11:37:49 -0000	1.1
  +++ portal-intro.xml	9 Dec 2003 10:21:56 -0000	1.2
  @@ -8,11 +8,16 @@
     <body> 
   	 <s1 title="The Apache Cocoon Portal"> 
   		<p>This is a demo of the Cocoon Portal Engine.</p>
  -            <p>The Cocoon portal page you currently view displays some so called
  -              <em>Coplets</em> (= Cocoon Portlets). Each coplet displays
  -              a select content.</p> 
  -       <p>For more information <fork href="http://cocoon.apache.org">visit
the Cocoon Homepage</fork>.</p>
  -   </s1> 
  +        <p>The Cocoon portal page you currently view displays some so called
  +          <em>Coplets</em> (= Cocoon Portlets). Each coplet displays
  +          a select content.</p> 
  +        <p>The different tabs display/demonstrate different aspects of the portal.</p>
  +        <ul>
  +          <li>The TabDemo1 shows a tab inside a tab, which is useful for structuring
content.</li>
  +          <li>The TabDemo2 shows the same content as TabDemo2 but with just a different
stylesheet for the tab.</li>
  +        </ul>
  +        <p>For more information <fork href="http://cocoon.apache.org">visit
the Cocoon Homepage</fork>.</p>
  +     </s1> 
   
     </body>
   </document>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/skins/basic/styles/linktab.xsl
  
  Index: linktab.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" 
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
  <!-- Process a tab  -->
  <xsl:template match="linktab-layout">
  <!-- ~~~~~ Begin body table ~~~~~ -->
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <!-- ~~~~~ Begin tab row ~~~~~ -->
    <tr vAlign="top">
    <td width="20%" align="top">
    <br/>
    &#160;Select:<br/><br/>
       <xsl:for-each select="named-item">
       
        <xsl:choose>
          <xsl:when test="not(@selected)">
            &#160;&#160;&#160;<a href="{@parameter}"><xsl:value-of select="@name"/></a><br/><br/>
          </xsl:when>
          <xsl:otherwise>
            &#160;&#160;&#160;<b><xsl:value-of select="@name"/></b><br/><br/>
          </xsl:otherwise>
        </xsl:choose> 
        </xsl:for-each>
    </td>
  				<td width="80%" align="top">
  					<xsl:apply-templates select="named-item"/>
  				</td>
    </tr>
  </table>
  </xsl:template>
  
  <xsl:template match="named-item">
    <xsl:apply-templates />
  </xsl:template>
  
  <!-- Copy all and apply templates -->
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.6       +3 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
  
  Index: CopletModule.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CopletModule.java	20 Oct 2003 13:36:42 -0000	1.5
  +++ CopletModule.java	9 Dec 2003 10:21:56 -0000	1.6
  @@ -140,7 +140,8 @@
               Object value = jxpathContext.getValue(name);
                   
               if (value == null) {
  -                throw new ConfigurationException("Could not find value for expression "+name);
  +                return null;
  +                //throw new ConfigurationException("Could not find value for expression
"+name);
               }
                   
               return value.toString();
  
  
  
  1.5       +2 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizableDescription.java
  
  Index: AbstractAspectalizableDescription.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizableDescription.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractAspectalizableDescription.java	3 Jul 2003 09:26:03 -0000	1.4
  +++ AbstractAspectalizableDescription.java	9 Dec 2003 10:21:56 -0000	1.5
  @@ -82,6 +82,7 @@
        * Return the description for an aspect
        */
       public AspectDescription getAspectDescription(String name) {
  +        if ( name == null ) return null;
           AspectDescription desc = null;
           Iterator i = this.aspects.iterator();
           while (desc == null && i.hasNext() ) {
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/skins/common/styles/linktab.xsl
  
  Index: linktab.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" 
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
  <!-- Process a tab  -->
  <xsl:template match="linktab-layout">
  <!-- ~~~~~ Begin body table ~~~~~ -->
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <!-- ~~~~~ Begin tab row ~~~~~ -->
    <tr vAlign="top">
    <td width="20%" align="top">
    <br/>
    &#160;Select:<br/><br/>
       <xsl:for-each select="named-item">
       
        <xsl:choose>
          <xsl:when test="not(@selected)">
            &#160;&#160;&#160;<a href="{@parameter}"><xsl:value-of select="@name"/></a><br/><br/>
          </xsl:when>
          <xsl:otherwise>
            &#160;&#160;&#160;<b><xsl:value-of select="@name"/></b><br/><br/>
          </xsl:otherwise>
        </xsl:choose> 
        </xsl:for-each>
    </td>
  				<td width="80%" align="top">
  					<xsl:apply-templates select="named-item"/>
  				</td>
    </tr>
  </table>
  </xsl:template>
  
  <xsl:template match="named-item">
    <xsl:apply-templates />
  </xsl:template>
  
  <!-- Copy all and apply templates -->
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.10      +49 -1     cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml
  
  Index: portal.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- portal.xml	29 Sep 2003 11:37:50 -0000	1.9
  +++ portal.xml	9 Dec 2003 10:21:56 -0000	1.10
  @@ -168,4 +168,52 @@
               </item>
           </composite-layout>
       </named-item>
  -</composite-layout>
  \ No newline at end of file
  +    <named-item name="TabDemo1">
  +        <composite-layout static="true" name="tab">
  +		    <named-item name="One">
  +                <coplet-layout name="coplet">
  +                    <parameter name="title" value="ML's Weblog" />
  +                    <parameter name="bgcolor" value="#ffff00" />
  +                    <coplet-instance-data>ML Weblog-1</coplet-instance-data>
  +                </coplet-layout>
  +		    </named-item>
  +		    <named-item name="Two">
  +                <coplet-layout name="coplet">
  +                    <parameter name="title" value="CZ's Weblog" />
  +                    <parameter name="bgcolor" value="#ffff00" />
  +                    <coplet-instance-data>CZ Weblog-1</coplet-instance-data>
  +                </coplet-layout>
  +		    </named-item>
  +		    <named-item name="Three">
  +	            <coplet-layout name="coplet">
  +	                <parameter name="title" value="Cocoon Overview" />
  +	                <coplet-instance-data>Overview-1</coplet-instance-data>
  +	            </coplet-layout>
  +		    </named-item>
  +        </composite-layout>
  +    </named-item>
  +    <named-item name="TabDemo2">
  +        <composite-layout static="true" name="linktab">
  +            <named-item name="One">
  +	            <coplet-layout name="coplet">
  +	                <parameter name="title" value="ML's Weblog" />
  +	                <parameter name="bgcolor" value="#ffff00" />
  +	                <coplet-instance-data>ML Weblog-1</coplet-instance-data>
  +	            </coplet-layout>
  +		    </named-item>
  +		    <named-item name="Two">
  +                <coplet-layout name="coplet">
  +                    <parameter name="title" value="CZ's Weblog" />
  +                    <parameter name="bgcolor" value="#ffff00" />
  +                    <coplet-instance-data>CZ Weblog-1</coplet-instance-data>
  +                </coplet-layout>
  +		    </named-item>
  +		    <named-item name="Three">
  +                <coplet-layout name="coplet">
  +                    <parameter name="title" value="Cocoon Overview" />
  +                    <coplet-instance-data>Overview-1</coplet-instance-data>
  +                </coplet-layout>
  +		    </named-item>
  +		</composite-layout>
  +    </named-item>
  +</composite-layout>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/CopletSetDataAction.java
  
  Index: CopletSetDataAction.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.acting;
  
  import java.util.Map;
  
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.cocoon.acting.ServiceableAction;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.cocoon.portal.Constants;
  import org.apache.cocoon.portal.PortalService;
  import org.apache.commons.jxpath.JXPathContext;
  
  /**
   * Using this action, you can set values in a coplet
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: CopletSetDataAction.java,v 1.1 2003/12/09 10:21:56 cziegeler Exp $
   */
  public class CopletSetDataAction 
  extends ServiceableAction {
  
  	public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
source, Parameters parameters) 
      throws Exception {
          PortalService portalService = null;
          try {
  
              portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
  
              // determine coplet id
              String copletId = null;            
              Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
              if (context != null) {
                  copletId = (String)context.get(Constants.COPLET_ID_KEY);
              } else {
                  copletId = (String)objectModel.get(Constants.COPLET_ID_KEY);
              
                  // set portal name
                  portalService.setPortalName((String)objectModel.get(Constants.PORTAL_NAME_KEY));
              }
          
              if (copletId == null) {
                  throw new ConfigurationException("copletId must be passed in the object
model either directly (e.g. by using ObjectModelAction) or within the parent context.");
              }
          
              JXPathContext jxpathContext = JXPathContext.newContext(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId));
              // now traverse parameters:
              // parameter name is path
              // parameter value is value
              // if the value is null or empty, the value is not set!
              final String[] names = parameters.getNames();
              if ( names != null ) {
                  for(int i=0; i<names.length; i++) {
                      final String path = names[i];
                      final String value = parameters.getParameter(path, null );
                      if ( value != null && value.trim().length() > 0 ) {
                          jxpathContext.setValue(path, value);
                      }
                  }
              }
              
              return EMPTY_MAP;
          
          } catch (ServiceException e) {
              throw new ConfigurationException("ComponentException ", e);
          } finally {
              this.manager.release(portalService);
          }
  	}
  }
  
  
  

Mime
View raw message