You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/21 00:31:22 UTC

svn commit: r613702 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java

Author: hlship
Date: Sun Jan 20 15:31:16 2008
New Revision: 613702

URL: http://svn.apache.org/viewvc?rev=613702&view=rev
Log:
TAPESTRY-1639: Components that generate hyperlinks (ActionLink, PageLink, EventLink) should have a getLink() method to retrieve the link as generated

Modified:
    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/AbstractLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractLink.java?rev=613702&r1=613701&r2=613702&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 Sun Jan 20 15:31:16 2008
@@ -42,6 +42,8 @@
     @Inject
     private ComponentResources _resources;
 
+    private Link _link;
+
     private final String buildHref(Link link)
     {
         String href = link.toURI();
@@ -51,6 +53,7 @@
         return href + "#" + _anchor;
     }
 
+
     /**
      * Writes an <a> element with the provided link as the href attribute.  A call to {@link
      * org.apache.tapestry.MarkupWriter#end()} is <em>not</em> provided.            Automatically appends an anchor if
@@ -70,6 +73,20 @@
         _resources.renderInformalParameters(writer);
 
         _componentInvocationMap.store(e, link);
+
+        _link = link;
+    }
+
+    /**
+     * Returns the most recently rendered {@link org.apache.tapestry.Link} for this component.  Subclasses calculate
+     * their link value as they render, and the value is valid until the end of the request, or the next time the same
+     * component renders itself (if inside a loop).
+     *
+     * @return the most recent link, or null
+     */
+    public Link getLink()
+    {
+        return _link;
     }
 
     /**