cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r124363 - /cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java
Date Thu, 06 Jan 2005 11:28:47 GMT
Author: cziegeler
Date: Thu Jan  6 03:28:45 2005
New Revision: 124363

URL: http://svn.apache.org/viewcvs?view=rev&rev=124363
Log:
Support for self as target
Modified:
   cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java?view=diff&rev=124363&p1=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java&r1=124362&p2=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java&r2=124363
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/LinkTransformer.java
Thu Jan  6 03:28:45 2005
@@ -105,6 +105,9 @@
     /** The prefix */
     protected String prefix;
 
+    /** Handle target self as no target? */
+    protected boolean ignoreTargetSelf;
+    
     /**
      * @see AbstractTransformer#setup(SourceResolver, Map, String, Parameters)
      */
@@ -113,6 +116,8 @@
                       String src,
                       Parameters par)
     throws ProcessingException, SAXException, IOException {
+        this.ignoreTargetSelf = par.getParameterAsBoolean("ignore-target-self", false);
+        
         this.copletInstanceData =
             ProxyTransformer.getInstanceData(
                 this.manager,
@@ -165,7 +170,7 @@
      */
     public void startElement(String uri, String name, String raw,
                              Attributes attributes)
-        throws SAXException {
+    throws SAXException {
 
         if ("form".equalsIgnoreCase(name)) {
             handleTag(
@@ -183,14 +188,14 @@
         } else if ("link".equalsIgnoreCase(name)) {
             handleTag("href", uri, name, raw, attributes, false, false);
         } else if ("a".equalsIgnoreCase(name)) {
-            handleTag(
-                "href",
-                uri,
-                name,
-                raw,
-                attributes,
-                true,
-                (attributes.getIndex("target") > -1));
+            boolean direct;
+            final String v = attributes.getValue("target");
+            if ( v == null || (this.ignoreTargetSelf && v.equals("self")) ) {
+                direct = false;
+            } else {
+                direct = true;
+            }
+            handleTag("href", uri, name, raw, attributes, true, direct);
         } else if ("menu-item".equalsIgnoreCase(name)) {
             handleTag("href", uri, name, raw, attributes, true, false);
         } else if ("input".equalsIgnoreCase(name)) {
@@ -208,7 +213,7 @@
      * @see org.xml.sax.ContentHandler#endElement(String, String, String)
      */
     public void endElement(String uri, String name, String raw)
-        throws SAXException {
+    throws SAXException {
         String elementName = null;
 
         if (!elementStack.empty()) {
@@ -277,7 +282,14 @@
             || remoteURI.startsWith("mailto:")) {
             super.startElement(uri, elementName, raw, attributes);
         } else {
-            if (attributes.getIndex("target") > -1 || direct) {
+            boolean evalTarget;
+            final String v = attributes.getValue("target");
+            if ( v == null || (this.ignoreTargetSelf && v.equals("self")) ) {
+                evalTarget = false;
+            } else {
+                evalTarget = true;
+            }
+            if (evalTarget || direct) {
                 try {
                     remoteURI =
                         ProxyTransformer.resolveURI(remoteURI, documentBase);

Mime
View raw message