Author: abelevich
Date: 2007-09-26 08:43:17 -0400 (Wed, 26 Sep 2007)
New Revision: 3127
Modified:
branches/3.1.x/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
Log:
RF-403 Tab panel should not apply tabs with the same names
Modified:
branches/3.1.x/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
---
branches/3.1.x/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-09-26
12:41:25 UTC (rev 3126)
+++
branches/3.1.x/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-09-26
12:43:17 UTC (rev 3127)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@@ -55,6 +56,7 @@
public final static String ACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-act
rich-tabhdr-cell-active";
public final static String INACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-inact
rich-tabhdr-cell-inactive";
public final static String DISABLED_CELL_CLASSES = "dr-tbpnl-tbcell-dsbld
rich-tabhdr-cell-disabled";
+ private final String TABS_WITH_SAME_NAMES_ERROR = "tabs with the same name not
allowed";
protected Class getComponentClass() {
return UITabPanel.class;
@@ -309,7 +311,9 @@
boolean clientSide =
UISwitchablePanel.CLIENT_METHOD.equals(pane.getSwitchType());
TabInfoCollector tabInfoCollector = getTabInfoCollector();
-
+
+ UITab prevTab = null;
+
for (Iterator iter = pane.getRenderedTabs(); iter.hasNext();) {
UITab tab = (UITab) iter.next();
boolean active = activeTab == tab;
@@ -318,12 +322,20 @@
if (!clientSide) {
clientSide =
UISwitchablePanel.CLIENT_METHOD.equals(tab.getSwitchTypeOrDefault());
}
-
+
+ if(prevTab != null){
+ if(prevTab.getName().equals(tab.getName())){
+ throw new FacesException(TABS_WITH_SAME_NAMES_ERROR);
+ };
+ }
+
tab.encodeTab(context, active);
if (!tab.isDisabled()) {
tabs.add(tabInfoCollector.collectTabInfo(context, tab));
}
+
+ prevTab = tab;
}
// Store flag for exist client-side tabs.
Show replies by date