You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by id...@apache.org on 2008/01/28 20:27:30 UTC
svn commit: r616009 - in /myfaces/tobago/trunk/core/src:
main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java
Author: idus
Date: Mon Jan 28 11:27:27 2008
New Revision: 616009
URL: http://svn.apache.org/viewvc?rev=616009&view=rev
Log:
TOBAGO-608: More flexible handling of value lists for markup and renderedPartially attributes
Added:
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?rev=616009&r1=616008&r2=616009&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Mon Jan 28 11:27:27 2008
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.commons.lang.StringUtils;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_LINK;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_ONCLICK;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ALIGN;
@@ -109,11 +110,11 @@
public static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
public static final Class[] VALUE_CHANGE_LISTENER_ARGS = {ValueChangeEvent.class};
public static final Class[] VALIDATOR_ARGS = {FacesContext.class, UIComponent.class, Object.class};
+ private static final String LIST_SEPARATOR_CHARS = ", ";
private ComponentUtil() {
}
-
public static boolean hasErrorMessages(FacesContext context) {
for (Iterator iter = context.getMessages(); iter.hasNext();) {
FacesMessage message = (FacesMessage) iter.next();
@@ -369,7 +370,7 @@
if (UIComponentTag.isValueReference(renderers)) {
command.setValueBinding(ATTR_RENDERED_PARTIALLY, createValueBinding(renderers));
} else {
- String[] components = renderers.split(",");
+ String[] components = splitList(renderers);
command.setRenderedPartially(components);
}
}
@@ -380,7 +381,7 @@
if (UIComponentTag.isValueReference(styleClasses)) {
component.setValueBinding(ATTR_STYLE_CLASS, createValueBinding(styleClasses));
} else {
- String[] classes = styleClasses.split("[, ]");
+ String[] classes = splitList(styleClasses);
if (classes.length > 0) {
StyleClasses styles = StyleClasses.ensureStyleClasses(component);
for (String clazz : classes) {
@@ -397,7 +398,7 @@
if (UIComponentTag.isValueReference(markup)) {
markupComponent.setValueBinding(ATTR_MARKUP, createValueBinding(markup));
} else {
- String[] markups = markup.split(",");
+ String[] markups = splitList(markup);
((SupportsMarkup) markupComponent).setMarkup(markups);
}
} else {
@@ -1316,4 +1317,9 @@
// we should reset rowIndex on UIData
uiData.setRowIndex(oldRowIndex);
}
+
+ static String[] splitList(String renderers) {
+ return StringUtils.split(renderers, LIST_SEPARATOR_CHARS);
+ }
+
}
Added: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java?rev=616009&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java (added)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/ComponentUtilUnitTest.java Mon Jan 28 11:27:27 2008
@@ -0,0 +1,32 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+
+public class ComponentUtilUnitTest extends TestCase {
+
+ public void testSplitList() {
+ Assert.assertArrayEquals(new String[]{"ab", "cd"}, ComponentUtil.splitList("ab cd"));
+ Assert.assertArrayEquals(new String[]{"ab", "cd"}, ComponentUtil.splitList("ab cd"));
+ Assert.assertArrayEquals(new String[]{"ab", "cd"}, ComponentUtil.splitList("ab, cd"));
+ Assert.assertArrayEquals(new String[]{"ab", "cd"}, ComponentUtil.splitList("ab , cd"));
+ Assert.assertArrayEquals(new String[]{"ab", "cd"}, ComponentUtil.splitList("ab,,cd"));
+ }
+}