click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r1075854 - in /click/trunk/click/extras: src/org/apache/click/extras/panel/TabbedPanel.java test/org/apache/click/extras/panel/TabbedPanelTest.java
Date Tue, 01 Mar 2011 15:54:13 GMT
Author: sabob
Date: Tue Mar  1 15:54:13 2011
New Revision: 1075854

URL: http://svn.apache.org/viewvc?rev=1075854&view=rev
Log:
Added support for multiple TabbedPanels per page. CLK-753

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java
    click/trunk/click/extras/test/org/apache/click/extras/panel/TabbedPanelTest.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java?rev=1075854&r1=1075853&r2=1075854&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java Tue Mar  1
15:54:13 2011
@@ -323,7 +323,7 @@ public class TabbedPanel extends Panel i
     public void setName(String name) {
         super.setName(name);
         ActionLink localTabLink = getTabLink();
-        localTabLink.setName(getName() + "-tabLink");
+        localTabLink.setName("tabLink-" + getName());
         add(localTabLink);
     }
 

Modified: click/trunk/click/extras/test/org/apache/click/extras/panel/TabbedPanelTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/org/apache/click/extras/panel/TabbedPanelTest.java?rev=1075854&r1=1075853&r2=1075854&view=diff
==============================================================================
--- click/trunk/click/extras/test/org/apache/click/extras/panel/TabbedPanelTest.java (original)
+++ click/trunk/click/extras/test/org/apache/click/extras/panel/TabbedPanelTest.java Tue Mar
 1 15:54:13 2011
@@ -64,17 +64,41 @@ public class TabbedPanelTest extends Tes
         assertEquals("panel2", activePanelName);
     }
 
+
+    /**
+     * Test that the request parameter <tt>tabPanelIndex-<TabbedPanelName></tt>
+     * sets the new active panel correctly.
+     */
+    public void testTabPanelIndexWithNameParameter() {
+        MockContext context = MockContext.initContext();
+
+        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
+
+        // Since tabbedPanel is zero index based, setting tabPanelIndex to 1
+        // should set the active panel to panel2
+        context.getMockRequest().setParameter("tabPanelIndex-" + tabbedPanel.getName(), "1");
+
+        tabbedPanel.add(new Panel("panel1"));
+        tabbedPanel.add(new Panel("panel2"));
+        tabbedPanel.onInit();
+        String activePanelName = tabbedPanel.getActivePanel().getName();
+
+        // By default panel2 should be the active panel
+        assertEquals("panel2", activePanelName);
+    }
+
     /**
      * Test that if user selects panel2, panel2 becomes the active panel.
      */
     public void testTabLinkClicked() {
         MockContext context = MockContext.initContext();
 
+        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
+
         // Simulate user selecting panel2
-        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
+        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink-" + tabbedPanel.getName());
         context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");
 
-        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
         tabbedPanel.add(new Panel("panel1"));
         tabbedPanel.add(new Panel("panel2"));
         tabbedPanel.onInit();
@@ -92,11 +116,12 @@ public class TabbedPanelTest extends Tes
     public void testTabListenerFired() {
         MockContext context = MockContext.initContext();
 
+        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
+
         // Simulate user selecting panel2
-        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
+        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink-" + tabbedPanel.getName());
         context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");
 
-        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
         tabbedPanel.add(new Panel("panel1"));
         tabbedPanel.add(new Panel("panel2"));
 



Mime
View raw message