diff --git a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WContainer.java b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WContainer.java index 1222a44673c..6f99f6c658c 100644 --- a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WContainer.java +++ b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WContainer.java @@ -50,4 +50,27 @@ public String toString() { sb.append(keys); return sb.toString(); } + + public boolean equals(Object something) { + boolean equals = true; + if (something == null) { + equals = false; + } + if (equals && !getClass().equals(something.getClass())) { + equals = false; + } + if (equals) { + ERD2WContainer other = (ERD2WContainer) something; + // verify name equality + if (name == null && other.name != null) { + equals = false; + } + if (equals && name != null && !name.equals(other.name)) { + equals = false; + } + // we don't verify display name and keys equality + } + return equals; + } + } diff --git a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/pages/ERD2WPage.java b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/pages/ERD2WPage.java index eeb763aa93c..161ef751c19 100644 --- a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/pages/ERD2WPage.java +++ b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/pages/ERD2WPage.java @@ -992,14 +992,16 @@ public NSArray sectionsForCurrentTab() { /** Returns the {@link er.directtoweb.ERD2WContainer} defining the current tab. */ public ERD2WContainer currentTab() { - if (_currentTab == null && tabSectionsContents() != null && tabSectionsContents().count() > 0) { - //If firstTab is not null, then try to find the tab named firstTab - Integer tabIndex = (Integer) d2wContext().valueForKey(Keys.tabIndex); - if(tabIndex!=null && tabIndex.intValue() <= tabSectionsContents().count()){ - setCurrentTab(tabSectionsContents().objectAtIndex(tabIndex.intValue())); - } - if(_currentTab==null) - setCurrentTab(tabSectionsContents().objectAtIndex(0)); + String tabName = (String) d2wContext().valueForKey(Keys.tabKey); + if (_currentTab == null && !ERXStringUtilities.stringIsNullOrEmpty(tabName)) { + for (ERD2WContainer aTab : tabSectionsContents()) { + if (tabName.equals(aTab.name)) { + setCurrentTab(aTab); + } + } + } + if (_currentTab == null) { + _currentTab = tabSectionsContents().objectAtIndex(0); } return _currentTab; }