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 2007/10/13 23:22:37 UTC

svn commit: r584455 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/components/PageLink.java test/java/org/apache/tapestry/corelib/components/PageLinkTest.java

Author: hlship
Date: Sat Oct 13 14:22:37 2007
New Revision: 584455

URL: http://svn.apache.org/viewvc?rev=584455&view=rev
Log:
TAPESTRY-1735: PageLink doesn't have a disabled parameter 

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java?rev=584455&r1=584454&r2=584455&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PageLink.java Sat Oct 13 14:22:37 2007
@@ -49,6 +49,13 @@
     @Environmental
     private PageRenderSupport _support;
 
+    /**
+     * 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;
 
     /**
@@ -63,6 +70,8 @@
 
     void beginRender(MarkupWriter writer)
     {
+        if (_disabled) return;
+
         _clientId = _support.allocateClientId(_resources.getId());
 
         Object[] activationContext = _context != null ? _context.toArray() : _emptyContext;
@@ -79,6 +88,8 @@
 
     void afterRender(MarkupWriter writer)
     {
+        if (_disabled) return;
+
         writer.end(); // <a>
     }
 
@@ -87,4 +98,8 @@
         return _clientId;
     }
 
+    void setDisabled(boolean disabled)
+    {
+        _disabled = disabled;
+    }
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java?rev=584455&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/PageLinkTest.java Sat Oct 13 14:22:37 2007
@@ -0,0 +1,44 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.corelib.components;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+/**
+ * Much of PageLink is tested via integration tests, but this is a place to test less well used
+ * behavior.
+ */
+public class PageLinkTest extends TapestryTestCase
+{
+    @Test
+    public void no_output_when_disabled()
+    {
+        MarkupWriter writer = mockMarkupWriter();
+
+        PageLink component = new PageLink();
+        
+        component.setDisabled(true);
+
+        replay();
+
+        component.beginRender(writer);
+        component.afterRender(writer);
+
+        verify();
+    }
+
+}