click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r1075825 - in /click/trunk/click: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/panel/TabbedPanel.java
Date Tue, 01 Mar 2011 14:15:04 GMT
Author: sabob
Date: Tue Mar  1 14:15:04 2011
New Revision: 1075825

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

Modified:
    click/trunk/click/documentation/docs/roadmap-changes.html
    click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java

Modified: click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/docs/roadmap-changes.html?rev=1075825&r1=1075824&r2=1075825&view=diff
==============================================================================
--- click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ click/trunk/click/documentation/docs/roadmap-changes.html Tue Mar  1 14:15:04 2011
@@ -199,6 +199,12 @@ Action support and light-weight stateful
       </div>
       <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
           <li class="change">
+              Added support for multiple TabbedPanels on a page. To programmatically
+              activate a specific TabbedPanel use the <tt>tabPanelIndex-&lt;panel-name&gt;</tt>
+              request parameter, for example <tt>tabPanelIndex-myTabbedPanel</tt>
+              [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-753">CLK-753</a>].
+          </li>
+          <li class="change">
               Improve fields to only be processed if they have an incoming request
               parameter. This improvement streamlines dynamic forms since fields
               added at runtime during s POST request won't bind their values and

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=1075825&r1=1075824&r2=1075825&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
14:15:04 2011
@@ -147,7 +147,7 @@ public class TabbedPanel extends Panel i
     protected Panel activePanel;
 
     /** The tab switch action link. */
-    protected ActionLink tabLink = new ActionLink("tabLink");
+    protected ActionLink tabLink;
 
     // ----------------------------------------------------------- Constructors
 
@@ -158,7 +158,6 @@ public class TabbedPanel extends Panel i
      */
     public TabbedPanel(String name) {
         super(name);
-        add(tabLink);
     }
 
     /**
@@ -169,7 +168,6 @@ public class TabbedPanel extends Panel i
      */
     public TabbedPanel(String name, String template) {
         super(name, template);
-        add(tabLink);
     }
 
     /**
@@ -181,7 +179,6 @@ public class TabbedPanel extends Panel i
      */
     public TabbedPanel(String name, String template, String id) {
         super(name, template, id);
-        add(tabLink);
     }
 
     /**
@@ -191,7 +188,6 @@ public class TabbedPanel extends Panel i
      */
     public TabbedPanel() {
         super();
-        add(tabLink);
     }
 
     // --------------------------------------------------------- Public Methods
@@ -317,6 +313,20 @@ public class TabbedPanel extends Panel i
         setTabListener(listener, listenerMethod);
     }
 
+     /**
+     * @see Control#setName(String)
+     *
+     * @param name of the control
+     * @throws IllegalArgumentException if the name is null
+     */
+    @Override
+    public void setName(String name) {
+        super.setName(name);
+        ActionLink localTabLink = getTabLink();
+        localTabLink.setName(getName() + "-tabLink");
+        add(localTabLink);
+    }
+
     /**
      * @see #setTabListener(ActionListener)
      *
@@ -431,6 +441,9 @@ public class TabbedPanel extends Panel i
      * @return the tab switching action link
      */
     public ActionLink getTabLink() {
+        if (tabLink == null) {
+            tabLink = new ActionLink();
+        }
         return tabLink;
     }
 
@@ -465,6 +478,9 @@ public class TabbedPanel extends Panel i
      * <p/>
      * If <tt>tabPanelIndex</tt> request parameter is present, this value will
be
      * used to specify the active panel. The panel index is a zero based integer.
+     * <p/>
+     * If multiple TabbedPanels are present on a form, use <tt>tabPanelIndex-&lt;panel-name&gt;</tt>
+     * to target a specific panel, for example: <tt>tabPanelIndex-myTabbedPanel</tt>.
      *
      * @see org.apache.click.Control#onInit()
      */
@@ -589,6 +605,9 @@ public class TabbedPanel extends Panel i
      *     If <tt>tabPanelIndex</tt> request parameter is present, this value
      *     will be used to specify the active panel. The panel index is a zero
      *     based integer.
+     *     <p/>
+     *     If multiple TabbedPanels are present on a form, use <tt>tabPanelIndex-&lt;panel-name&gt;</tt>
+     *     to target a specific panel, for example: <tt>tabPanelIndex-myTabbedPanel</tt>.
      *   </li>
      *   <li>
      *     If a specific tab panel is selected by the user, that panel will
@@ -598,7 +617,11 @@ public class TabbedPanel extends Panel i
      */
     protected void initActivePanel() {
         // Select panel specified by tabPanelIndex if defined
-        String tabPanelIndex = getContext().getRequestParameter("tabPanelIndex");
+        Context context = getContext();
+        String tabPanelIndex = context.getRequestParameter("tabPanelIndex-" + getName());
+        if (tabPanelIndex == null) {
+            tabPanelIndex = context.getRequestParameter("tabPanelIndex");
+        }
         if (NumberUtils.isNumber(tabPanelIndex)) {
             int tabIndex = Integer.parseInt(tabPanelIndex);
             if (tabIndex >= 0 && tabIndex < getPanels().size()) {



Mime
View raw message