tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r614985 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base: AbstractComponentActionLink.java AbstractLink.java
Date Thu, 24 Jan 2008 20:47:59 GMT
Author: hlship
Date: Thu Jan 24 12:47:50 2008
New Revision: 614985

URL: http://svn.apache.org/viewvc?rev=614985&view=rev
Log:
TAPESTRY-1887: Extend the AbstractLink class to provide access to the clientId and disabled
flag, as well as to the URL

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentActionLink.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentActionLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentActionLink.java?rev=614985&r1=614984&r2=614985&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentActionLink.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractComponentActionLink.java
Thu Jan 24 12:47:50 2008
@@ -22,7 +22,7 @@
 
 import java.util.List;
 
-public abstract class AbstractComponentActionLink extends AbstractLink implements ClientElement
+public abstract class AbstractComponentActionLink extends AbstractLink
 {
     /**
      * The context for the link (optional parameter). This list of values will be converted
into strings and included in
@@ -47,28 +47,19 @@
     @Environmental
     private ZoneSetup _zoneSetup;
 
-    /**
-     * If true, then then no link element is rendered (and no informal parameters as well).
The body is, however, still
-     * rendered.
-     */
-    @Parameter("false")
-    private boolean _disabled;
-
-    private String _clientId;
-
     void beginRender(MarkupWriter writer)
     {
-        if (_disabled) return;
+        if (isDisabled()) return;
 
-        _clientId = _support.allocateClientId(_resources.getId());
+        String clientId = _support.allocateClientId(_resources.getId());
 
         Object[] contextArray = _context == null ? new Object[0] : _context.toArray();
 
         Link link = createLink(contextArray);
 
-        writeLink(writer, _clientId, link);
+        writeLink(writer, clientId, link);
 
-        if (_zone != null) _zoneSetup.linkZone(_clientId, _zone);
+        if (_zone != null) _zoneSetup.linkZone(clientId, _zone);
     }
 
     /**
@@ -76,16 +67,11 @@
      */
     protected abstract Link createLink(Object[] eventContext);
 
-
     void afterRender(MarkupWriter writer)
     {
-        if (_disabled) return;
+        if (isDisabled()) return;
 
         writer.end(); // <a>
     }
 
-    public String getClientId()
-    {
-        return _clientId;
-    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java?rev=614985&r1=614984&r2=614985&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java
Thu Jan 24 12:47:50 2008
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.corelib.base;
 
+import org.apache.tapestry.ClientElement;
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.Link;
 import org.apache.tapestry.MarkupWriter;
@@ -28,7 +29,7 @@
  * Provides base utilities for classes that generate clickable links.
  */
 @SupportsInformalParameters
-public abstract class AbstractLink
+public abstract class AbstractLink implements ClientElement
 {
     @Inject
     private ComponentInvocationMap _componentInvocationMap;
@@ -39,11 +40,20 @@
     @Parameter(defaultPrefix = LITERAL_BINDING_PREFIX)
     private String _anchor;
 
+    /**
+     * If true, then then no link element is rendered (and no informal parameters as well).
The body is, however, still
+     * rendered.
+     */
+    @Parameter("false")
+    private boolean _disabled;
+
     @Inject
     private ComponentResources _resources;
 
     private Link _link;
 
+    private String _clientId;
+
     private final String buildHref(Link link)
     {
         String href = link.toURI();
@@ -75,6 +85,7 @@
         _componentInvocationMap.store(e, link);
 
         _link = link;
+        _clientId = clientId;
     }
 
     /**
@@ -87,6 +98,24 @@
     public Link getLink()
     {
         return _link;
+    }
+
+    /**
+     * Returns the unique client id for this element. This is valid only after the component
has rendered (its start
+     * tag), and then only if the component is {@linkplain #isDisabled() enabled}.
+     */
+    public String getClientId()
+    {
+        return _clientId;
+    }
+
+    /**
+     * Returns true if the component is disabled (as per its disabled parameter). Disabled
link components should not
+     * render a tag, but should still render their body.
+     */
+    public boolean isDisabled()
+    {
+        return _disabled;
     }
 
     /**



Mime
View raw message