cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r489671 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java status.xml
Date Fri, 22 Dec 2006 15:08:45 GMT
Author: cziegeler
Date: Fri Dec 22 07:08:44 2006
New Revision: 489671

URL: http://svn.apache.org/viewvc?view=rev&rev=489671
Log:
Fix handling of missing special parameters for forms in NewEventLinkTransformer.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java?view=diff&rev=489671&r1=489670&r2=489671
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
Fri Dec 22 07:08:44 2006
@@ -19,6 +19,7 @@
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.event.impl.CopletLinkEvent;
 import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -152,27 +153,28 @@
 
             //form elements need hidden inputs to change request parameters
             if (formSpecialTreatment) {
-                int begin =
-                    eventLink.indexOf("cocoon-portal-action=")
-                        + "cocoon-portal-action=".length();
-                int end = eventLink.indexOf('&', begin);
-                if (end == -1) {
-                    end = eventLink.length();
+                int pos = eventLink.indexOf("cocoon-portal-action=");
+                if ( pos != -1 ) {
+                    int begin = pos + "cocoon-portal-action=".length();
+                    int end = eventLink.indexOf('&', begin);
+                    if (end == -1) {
+                        end = eventLink.length();
+                    }
+                    portalAction = eventLink.substring(begin, end);
                 }
-
-                portalAction = eventLink.substring(begin, end);
-
-                begin =
-                    eventLink.indexOf("cocoon-portal-event=")
-                        + "cocoon-portal-event=".length();
-                end = eventLink.indexOf('&', begin);
-                if (end == -1) {
-                    end = eventLink.length();
+                pos = eventLink.indexOf("cocoon-portal-event=");
+                if ( pos != -1 ) {
+                    int begin = pos + "cocoon-portal-event=".length();
+                    int end = eventLink.indexOf('&', begin);
+                    if (end == -1) {
+                        end = eventLink.length();
+                    }
+                    portalEvent = eventLink.substring(begin, end);
+                }
+                pos = eventLink.indexOf('?');
+                if ( pos != -1 ) {
+                    eventLink = eventLink.substring(0, eventLink.indexOf('?'));
                 }
-                portalEvent = eventLink.substring(begin, end);
-
-                eventLink =
-                    eventLink.substring(0, eventLink.indexOf('?'));
             }
 
             // insert event link
@@ -207,29 +209,21 @@
                                   String portalAction,
                                   String portalEvent)
     throws SAXException {
-        AttributesImpl attributes = new AttributesImpl();
-        attributes.addAttribute("", "type", "type", "CDATA", "hidden");
-        attributes.addAttribute(
-            "",
-            "name",
-            "name",
-            "CDATA",
-            "cocoon-portal-action");
-        attributes.addAttribute("", "value", "value", "CDATA", portalAction);
-        contentHandler.startElement("", "input", "input", attributes);
-        contentHandler.endElement("", "input", "input");
-
-        attributes = new AttributesImpl();
-        attributes.addAttribute("", "type", "type", "CDATA", "hidden");
-        attributes.addAttribute(
-            "",
-            "name",
-            "name",
-            "CDATA",
-            "cocoon-portal-event");
-        attributes.addAttribute("", "value", "value", "CDATA", portalEvent);
-        contentHandler.startElement("", "input", "input", attributes);
-        contentHandler.endElement("", "input", "input");
+        if ( portalAction != null ) {
+            final AttributesImpl attributes = new AttributesImpl();
+            attributes.addCDATAAttribute("type", "hidden");
+            attributes.addCDATAAttribute("name", "cocoon-portal-action");
+            attributes.addCDATAAttribute("value", portalAction);
+            XMLUtils.createElement(contentHandler, "input", attributes);
+        }
+ 
+        if ( portalEvent != null ) {
+            final AttributesImpl attributes = new AttributesImpl();
+            attributes.addCDATAAttribute("type", "hidden");
+            attributes.addCDATAAttribute("name", "cocoon-portal-event");
+            attributes.addCDATAAttribute("value", portalEvent);
+            XMLUtils.createElement(contentHandler, "input", attributes);
+        }
     }
 
     /**

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=489671&r1=489670&r2=489671
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Fri Dec 22 07:08:44 2006
@@ -182,6 +182,9 @@
   <changes>
   <release version="2.1.11" date="TBD">
     <action dev="CZ" type="fix">
+      Portal Block: Fix handling of missing special parameters for forms in NewEventLinkTransformer.
+    </action>
+    <action dev="CZ" type="fix">
       Auth Block: Make isUserInRole a static method.
     </action>
   </release>



Mime
View raw message