[richfaces-svn-commits] JBoss Rich Faces SVN: r354 - in trunk/richfaces/tabPanel/src: test/java/org/richfaces and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Apr 11 08:29:47 EDT 2007
Author: A.Skokov
Date: 2007-04-11 08:29:47 -0400 (Wed, 11 Apr 2007)
New Revision: 354
Added:
trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/
trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
Log:
test updated
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-11 12:14:57 UTC (rev 353)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -47,48 +47,48 @@
/**
* @author Nick Belaevski - nbelaevski at exadel.com
* created 12.01.2007
- *
+ *
*/
public class TabPanelRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
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";
-
+
protected Class getComponentClass() {
return UITabPanel.class;
}
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
-
+
UITabPanel panel = (UITabPanel) component;
-
+
String clientId = component.getClientId(context);
Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
UITab eventTab = null;
-
- for (Iterator tabsIterator = panel.getTabs();
+
+ for (Iterator tabsIterator = panel.getTabs();
tabsIterator.hasNext() && eventTab == null;) {
-
+
UITab tab = (UITab) tabsIterator.next();
if (!tab.isRendered() || tab.isDisabled()) {
continue;
}
String tabClientId = tab.getClientId(context);
- if (requestParameterMap.containsKey(tabClientId) ||
+ if (requestParameterMap.containsKey(tabClientId) ||
requestParameterMap.containsKey(tabClientId + "_server_submit")) {
-
+
eventTab = tab;
}
}
-
+
if (eventTab != null) {
new SwitchablePanelSwitchEvent(panel, null, eventTab).queue();
new ActionEvent(eventTab).queue();
-
+
if (UISwitchablePanel.AJAX_METHOD.equals(eventTab.getSwitchType())) {
new AjaxEvent(eventTab).queue();
}
@@ -104,11 +104,11 @@
private final JSReference JSR_ACTIVE_CLASS = new JSReference("activeClass");
private final JSReference JSR_ID = new JSReference("id");
private final JSReference JSR_INACTIVE_CLASS = new JSReference("inactiveClass");
-
+
private final JSReference JSR_CELL_ACTIVE_CLASS = new JSReference("cellActiveClass");
private final JSReference JSR_CELL_INACTIVE_CLASS = new JSReference("cellInactiveClass");
-
+
public Object collectTabInfo(FacesContext context, UITab tab) {
Map info = new HashMap();
info.put(JSR_ID, tab.getClientId(context));
@@ -117,11 +117,11 @@
info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
-
+
return info;
}
};
-
+
/**
* @param context
* @param component
@@ -154,7 +154,7 @@
* @param name
* @return
*/
- private static boolean parameterPresent(String style, String name) {
+ protected static boolean parameterPresent(String style, String name) {
if (style != null && style.length() > 0) {
String[] styles = style.split(";");
for (int i = 0; i < styles.length; i++) {
@@ -177,11 +177,11 @@
public void encodeTabs(FacesContext context, UITabPanel tabPanel) throws IOException {
ComponentVariables componentVariables = ComponentsVariableResolver.getVariables(this, tabPanel);
-
+
Object value = tabPanel.getValue();
if (value instanceof String) {
if (((String) value).length() == 0) {
- value = null;
+ value = null;
}
}
if (value == null){
@@ -191,15 +191,15 @@
UITabPanel pane = tabPanel;
UITab firstRenderedTab = null;
UITab activeTab = null;
-
+
for (Iterator iter = pane.getTabs(); iter.hasNext() && activeTab == null;) {
UITab tab = (UITab) iter.next();
-
+
if (tab.isRendered()) {
if (firstRenderedTab == null) {
firstRenderedTab = tab;
}
-
+
if (useFirstRenderedTab) {
activeTab = firstRenderedTab;
} else if (value.equals(tab.getName())) {
@@ -218,7 +218,7 @@
}
}
}
-
+
if (activeTab == null) {
throw new IllegalStateException("No active tabs!");
} else {
@@ -234,12 +234,12 @@
UITab tab = (UITab) iter.next();
boolean active = activeTab == tab;
tab.setActive(active);
-
+
if (tab.isRendered()) {
if (!clientSide) {
clientSide = UISwitchablePanel.CLIENT_METHOD.equals(tab.getSwitchType());
}
-
+
tab.encodeTab(context, active);
if (!tab.isDisabled()) {
@@ -252,7 +252,7 @@
componentVariables.setVariable("clientSide", new Boolean(clientSide));
componentVariables.setVariable("tabs", tabs);
}
-
+
public static String getActiveTabCellClass(UITab tab) {
return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
}
@@ -265,7 +265,7 @@
return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
}
-
+
public static String getActiveTabClass(UITab tab) {
return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
}
@@ -280,7 +280,7 @@
/**
* Encode JavaScript function for switch tabs.
- *
+ *
* @param templateContext
* @throws IOException
*/
@@ -304,6 +304,6 @@
protected TabInfoCollector getTabInfoCollector() {
return collector;
}
-
+
}
Modified: trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 12:14:57 UTC (rev 353)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -28,6 +28,7 @@
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.html.HtmlTab;
import org.richfaces.component.html.HtmlTabPanel;
+import org.richfaces.renderkit.TabPanelRendererBase;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlForm;
Added: trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java (rev 0)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+public class TabPanelRendererBaseTest extends AbstractAjax4JsfTestCase {
+ private static String STYLE = "test1:1;test2:2; test3: 3; test4 :4;test5 : 5; test6:6; test7:;test8; test9";
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public TabPanelRendererBaseTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testParameterPresent() throws Exception {
+ assertFalse(TabPanelRendererBase.parameterPresent(null, "test0"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test1"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test2"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test3"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test4"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test5"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test6"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test7"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test8"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test9"));
+ }
+}
More information about the richfaces-svn-commits
mailing list