cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r330304 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: resources/js/cocoon-portal.js transformation/AbstractCopletTransformer.java transformation/CopletTransformer.java
Date Wed, 02 Nov 2005 18:23:51 GMT
Author: cziegeler
Date: Wed Nov  2 10:23:15 2005
New Revision: 330304

URL: http://svn.apache.org/viewcvs?rev=330304&view=rev
Log:
Enable ajax for coplet content

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/resources/js/cocoon-portal.js
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/resources/js/cocoon-portal.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/resources/js/cocoon-portal.js?rev=330304&r1=330303&r2=330304&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/resources/js/cocoon-portal.js
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/resources/js/cocoon-portal.js
Wed Nov  2 10:23:15 2005
@@ -17,7 +17,11 @@
 
 cocoon.portal.process = function(uri) {
   var req = cocoon.ajax.newXMLHttpRequest();
-  req.open("GET", uri + "&cocoon-ajax=true");
+  if ( uri.indexOf("?") == -1 ) {
+    req.open("GET", uri + "?cocoon-ajax=true");
+  } else {
+    req.open("GET", uri + "&cocoon-ajax=true");
+  }
   req.onreadystatechange = function() {
     if (req.readyState == 4) {
       cocoon.portal.handleBrowserUpdate(req);

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java?rev=330304&r1=330303&r2=330304&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
Wed Nov  2 10:23:15 2005
@@ -59,7 +59,7 @@
 
     /** The portal service. @since 2.1.8 */
     protected PortalService portalService;
-    
+
     /**
      * Try to get the coplet instance data belonging to the current request
      * @return The coplet instance data

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java?rev=330304&r1=330303&r2=330304&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Wed Nov  2 10:23:15 2005
@@ -20,6 +20,8 @@
 import java.util.Enumeration;
 import java.util.List;
 
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.wrapper.RequestParameters;
 import org.apache.cocoon.portal.LinkService;
@@ -55,14 +57,10 @@
 public class CopletTransformer
 extends AbstractCopletTransformer {
 
-    /**
-     * The namespace URI to listen for.
-     */
+    /** The namespace URI to listen for. */
     public static final String NAMESPACE_URI = "http://apache.org/cocoon/portal/coplet/1.0";
 
-    /**
-     * The XML element name to listen for.
-     */
+    /** The XML element name to listen for: coplet. */
     public static final String COPLET_ELEM = "coplet";
 
     /**
@@ -71,29 +69,30 @@
     public static final String SELECT_ATTR = "select";
 
 
-    /**
-     * The XML element name to listen for.
-     */
+    /** The XML element name to listen for: link. */
     public static final String LINK_ELEM = "link";
 
-    /** Create a link containing several events */
+    /** Create a link containing several events. */
     public static final String LINKS_ELEM = "links";
 
-    /** Create a link containing several events */
+    /** Create a link containing several events. */
     public static final String PARAMETER_ELEM = "parameter";
 
-    /** The content for the links element */
+    /** The content for the links element. */
     public static final String CONTENT_ELEM = "content";
 
     /** Are we inside a links element? */
     protected boolean insideLinks;
 
-    /** The collected list of events */
+    /** The collected list of events. */
     protected List collectedEvents = new ArrayList();
 
-    /** The content of the links */
+    /** The content of the links. */
     protected XMLizable content;
 
+    /** use ajax? */
+    protected boolean useAjax = false;
+
     /**
      * Creates new CopletTransformer.
      */
@@ -101,7 +100,15 @@
         this.defaultNamespaceURI = NAMESPACE_URI;
     }
 
-    /* (non-Javadoc)
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration configuration) throws ConfigurationException {
+        super.configure(configuration);
+        this.useAjax = configuration.getChild("use-ajax").getValueAsBoolean(this.useAjax);
+    }
+
+    /**
      * @see org.apache.cocoon.transformation.AbstractSAXTransformer#setupTransforming()
      */
     public void setupTransforming()
@@ -276,7 +283,11 @@
         }
 
         if ( "html-link".equals(format) ) {
-            newAttrs.addCDATAAttribute("href", uri);
+            if ( this.useAjax ) {
+                newAttrs.addCDATAAttribute("href", "javascript:cocoon.portal.process('" +
uri + "');");
+            } else {
+                newAttrs.addCDATAAttribute("href", uri);                
+            }
             this.sendStartElementEvent("a", newAttrs);
             this.stack.push("a");
 



Mime
View raw message