JBoss Rich Faces SVN: r13014 - in trunk/ui/tree/src: main/java/org/richfaces and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-18 16:11:48 -0400 (Wed, 18 Mar 2009)
New Revision: 13014
Added:
trunk/ui/tree/src/main/java/org/richfaces/converter/
trunk/ui/tree/src/main/java/org/richfaces/converter/BaseTreeConverter.java
trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverter.java
trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorRowKeyConverter.java
trunk/ui/tree/src/main/java/org/richfaces/converter/TreeRowKeyConverter.java
trunk/ui/tree/src/test/java/org/richfaces/converter/
trunk/ui/tree/src/test/java/org/richfaces/converter/BaseTreeConverterTest.java
trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverterTest.java
trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorRowKeyConverterTest.java
trunk/ui/tree/src/test/java/org/richfaces/converter/TreeRowKeyConverterTest.java
Modified:
trunk/ui/tree/src/main/config/component/tree.xml
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4351
Modified: trunk/ui/tree/src/main/config/component/tree.xml
===================================================================
--- trunk/ui/tree/src/main/config/component/tree.xml 2009-03-18 20:10:19 UTC (rev 13013)
+++ trunk/ui/tree/src/main/config/component/tree.xml 2009-03-18 20:11:48 UTC (rev 13014)
@@ -336,7 +336,7 @@
<description>Keys of the nodes (without subtree) to be updated for ajax request risen by the node itself</description>
</property>
- <property hidden="true">
+ <property>
<name>rowKeyConverter</name>
</property>
@@ -360,5 +360,20 @@
</component>
&listeners;
+
+ <converter generate="false">
+ <id>org.richfaces.TreeRowKeyConverter</id>
+ <classname>org.richfaces.converter.TreeRowKeyConverter</classname>
+ </converter>
+
+ <converter generate="false">
+ <id>org.richfaces.TreeAdaptorRowKeyConverter</id>
+ <classname>org.richfaces.converter.TreeAdaptorRowKeyConverter</classname>
+ </converter>
+
+ <converter generate="false">
+ <id>org.richfaces.TreeAdaptorIntegerRowKeyConverter</id>
+ <classname>org.richfaces.converter.TreeAdaptorIntegerRowKeyConverter</classname>
+ </converter>
</components>
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2009-03-18 20:10:19 UTC (rev 13013)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -1051,12 +1051,16 @@
@Override
public Converter getRowKeyConverter() {
- return KEY_CONVERTER;
+ Converter converter = super.getRowKeyConverter();
+ if (converter == null) {
+ converter = KEY_CONVERTER;
+ }
+ return converter;
}
@Override
public void setRowKeyConverter(Converter rowKeyConverter) {
- throw new UnsupportedOperationException();
+ super.setRowKeyConverter(rowKeyConverter);
}
/**
Added: trunk/ui/tree/src/main/java/org/richfaces/converter/BaseTreeConverter.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/converter/BaseTreeConverter.java (rev 0)
+++ trunk/ui/tree/src/main/java/org/richfaces/converter/BaseTreeConverter.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,121 @@
+package org.richfaces.converter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.convert.Converter;
+
+import org.richfaces.model.AbstractTreeDataModel;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public abstract class BaseTreeConverter implements Converter {
+
+ private static final Pattern unescapePattern = Pattern.compile("_(:|_)|_(x[0-9A-Fa-f]{2}|[0-9A-Fa-f]{4})?|(:)");
+
+ //private static final Pattern htmlEscapePattern = Pattern.compile(":|_|[^0-9a-zA-Z]");
+
+ private static final Pattern xhtmlEscapePattern = Pattern.compile(":|_|[^A-Za-z\\-\\.0-9\\xC0-\\xD6\\xD8-\\xF6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\xB7\\u0300-\\u036F\\u203F-\\u2040]");
+
+ private String escape(String s) {
+ Matcher matcher = xhtmlEscapePattern.matcher(s);
+ StringBuilder sb = new StringBuilder(s.length());
+
+ int start = 0;
+
+ while (matcher.find()) {
+ int idx = matcher.start();
+ sb.append(s, start, idx);
+ sb.append('_');
+
+ char c = s.charAt(idx);
+ if (c == ':' || c == '_') {
+ sb.append(c); // _: or __
+ } else {
+ String asHex = Integer.toHexString(c);
+ switch (asHex.length()) {
+
+ case 1:
+ sb.append("x0"); // _x05
+ break;
+ case 2:
+ sb.append("x"); // _xef
+ break;
+ case 3:
+ sb.append("0"); // _0fed
+ break;
+ case 4:
+ //no padding required
+ // _fcda
+ break;
+
+ default:
+ throw new IllegalArgumentException();
+ }
+
+ sb.append(asHex);
+ }
+
+ start = idx + 1;
+ }
+
+ if (start < s.length()) {
+ sb.append(s, start, s.length());
+ }
+
+ return sb.toString();
+ }
+
+ protected void appendToKeyString(StringBuilder builder, String segment) {
+ builder.append(escape(segment));
+ builder.append(AbstractTreeDataModel.SEPARATOR);
+ }
+
+ protected List<String> splitKeyString(String string) {
+ Matcher matcher = unescapePattern.matcher(string);
+
+ List<String> result = new ArrayList<String>();
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find()) {
+ if (matcher.group(3) == null) {
+ String oneChar = matcher.group(1);
+ if (oneChar != null) {
+ matcher.appendReplacement(sb, "$1");
+ } else {
+ matcher.appendReplacement(sb, "");
+ String hex = matcher.group(2);
+ if (hex != null) {
+ if (hex.charAt(0) == 'x') {
+ hex = hex.substring(1);
+ }
+
+ int h = Integer.parseInt(hex, 16);
+ sb.append((char) h);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+ } else {
+ matcher.appendReplacement(sb, "");
+ result.add(sb.toString());
+ sb.setLength(0);
+ }
+ }
+
+ matcher.appendTail(sb);
+
+ if (sb.length() != 0) {
+ result.add(sb.toString());
+ sb.setLength(0);
+ }
+
+ return result;
+ }
+
+}
Added: trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverter.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverter.java (rev 0)
+++ trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverter.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,16 @@
+package org.richfaces.converter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public class TreeAdaptorIntegerRowKeyConverter extends TreeAdaptorRowKeyConverter {
+
+ public static final String CONVERTER_ID = "org.richfaces.TreeAdaptorIntegerRowKeyConverter";
+
+ @Override
+ protected Object convertStringToModelKey(FacesContext context,
+ UIComponent component, String modelId, String value) {
+
+ return Integer.parseInt(value);
+ }
+}
Added: trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorRowKeyConverter.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorRowKeyConverter.java (rev 0)
+++ trunk/ui/tree/src/main/java/org/richfaces/converter/TreeAdaptorRowKeyConverter.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,107 @@
+package org.richfaces.converter;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+
+import org.ajax4jsf.Messages;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.model.ListRowKey;
+import org.richfaces.model.StackingTreeModelKey;
+import org.richfaces.model.TreeRowKey;
+
+public class TreeAdaptorRowKeyConverter extends BaseTreeConverter {
+
+ public static final String CONVERTER_ID = "org.richfaces.TreeAdaptorRowKeyConverter";
+
+ protected Object convertStringToModelKey(FacesContext context, UIComponent component,
+ String modelId, String value) {
+
+ return value;
+ }
+
+ protected String convertModelKeyToString(FacesContext context, UIComponent component,
+ String modelId, Object value) {
+
+ return value.toString();
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (component == null) {
+ throw new NullPointerException("component");
+ }
+
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+
+ try {
+ List<StackingTreeModelKey<?>> keys = new ArrayList<StackingTreeModelKey<?>>();
+ Iterator<String> iterator = splitKeyString(value).iterator();
+ while (iterator.hasNext()) {
+ String modelId = iterator.next();
+ String modelKey = iterator.next();
+
+ Object convertedModelKey = convertStringToModelKey(context, component, modelId, modelKey);
+ keys.add(new StackingTreeModelKey<Object>(modelId, convertedModelKey));
+ }
+
+
+ return new ListRowKey<StackingTreeModelKey<?>>(keys);
+ } catch (Exception e) {
+ Object label = MessageUtil.getLabel(context, component);
+ String summary = Messages.getMessage(Messages.COMPONENT_CONVERSION_ERROR, label, value);
+
+ throw new ConverterException(new FacesMessage(summary), e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (component == null) {
+ throw new NullPointerException("component");
+ }
+
+ if (value == null) {
+ return null;
+ }
+
+ try {
+ StringBuilder sb = new StringBuilder();
+ TreeRowKey<StackingTreeModelKey<?>> treeRowKey = (TreeRowKey<StackingTreeModelKey<?>>) value;
+ Iterator<StackingTreeModelKey<?>> iterator = treeRowKey.iterator();
+ while (iterator.hasNext()) {
+ StackingTreeModelKey<?> key = iterator.next();
+ String modelId = key.getModelId();
+ appendToKeyString(sb, modelId);
+ Object modelKey = key.getModelKey();
+ String convertedModelKey = convertModelKeyToString(context, component, modelId, modelKey);
+ appendToKeyString(sb, convertedModelKey);
+ }
+
+ return sb.toString();
+ } catch (Exception e) {
+ Object label = MessageUtil.getLabel(context, component);
+ String summary = Messages.getMessage(Messages.COMPONENT_CONVERSION_ERROR, label, value);
+
+ throw new ConverterException(new FacesMessage(summary), e);
+ }
+ }
+}
Added: trunk/ui/tree/src/main/java/org/richfaces/converter/TreeRowKeyConverter.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/converter/TreeRowKeyConverter.java (rev 0)
+++ trunk/ui/tree/src/main/java/org/richfaces/converter/TreeRowKeyConverter.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,102 @@
+package org.richfaces.converter;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+
+import org.ajax4jsf.Messages;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.model.ListRowKey;
+import org.richfaces.model.TreeRowKey;
+
+public class TreeRowKeyConverter extends BaseTreeConverter {
+
+ public static final String CONVERTER_ID = "org.richfaces.TreeRowKeyConverter";
+
+ protected Object convertStringToKey(FacesContext context, UIComponent component, String value) {
+ return value;
+ }
+
+ protected String convertKeyToString(FacesContext context, UIComponent component, Object value) {
+ return value.toString();
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (component == null) {
+ throw new NullPointerException("component");
+ }
+
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+
+ try {
+ List<String> split = splitKeyString(value);
+ List<Object> result = new ArrayList<Object>(split.size());
+
+ Iterator<String> iterator = split.iterator();
+ while (iterator.hasNext()) {
+ String stringKey = iterator.next();
+ Object convertedKey = convertStringToKey(context, component, stringKey);
+ result.add(convertedKey);
+ }
+
+ return new ListRowKey<Object>(result);
+ } catch (Exception e) {
+ Object label = MessageUtil.getLabel(context, component);
+ String summary = Messages.getMessage(Messages.COMPONENT_CONVERSION_ERROR, label, value);
+
+ throw new ConverterException(new FacesMessage(summary), e);
+ }
+
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (component == null) {
+ throw new NullPointerException("component");
+ }
+
+ if (value == null) {
+ return null;
+ }
+
+ try {
+ TreeRowKey<?> key = (TreeRowKey<?>) value;
+ Iterator<?> iterator = key.iterator();
+ StringBuilder sb = new StringBuilder();
+
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ String convertedKey = convertKeyToString(context, component, next);
+
+ appendToKeyString(sb, convertedKey);
+ }
+
+ return sb.toString();
+ } catch (Exception e) {
+ Object label = MessageUtil.getLabel(context, component);
+ String summary = Messages.getMessage(Messages.COMPONENT_CONVERSION_ERROR, label, value);
+
+ throw new ConverterException(new FacesMessage(summary), e);
+ }
+
+ }
+
+}
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java 2009-03-18 20:10:19 UTC (rev 13013)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -62,7 +62,7 @@
assertFalse(iterator.hasNext());
- key = new ListRowKey<Long>(new Long(5));
+ key = new ListRowKey<Long>(null, new Long(5));
assertEquals(1, key.depth());
iterator = key.iterator();
assertTrue(iterator.hasNext());
@@ -70,7 +70,7 @@
assertFalse(iterator.hasNext());
- key = new ListRowKey<Long>(new ListRowKey<Long>(new Long(6)), new Long(7));
+ key = new ListRowKey<Long>(new ListRowKey<Long>(null, new Long(6)), new Long(7));
assertEquals(2, key.depth());
iterator = key.iterator();
assertTrue(iterator.hasNext());
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2009-03-18 20:10:19 UTC (rev 13013)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -564,7 +564,7 @@
defaultFacet.getChildren().add(input1);
tree.setNodeFace("node");
- tree.setRowKey(new ListRowKey("testId"));
+ tree.setRowKey(new ListRowKey(null, "testId"));
Iterator dataChildren = tree.dataChildren();
assertTrue(dataChildren.hasNext());
assertSame(treeNode, dataChildren.next());
Added: trunk/ui/tree/src/test/java/org/richfaces/converter/BaseTreeConverterTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/converter/BaseTreeConverterTest.java (rev 0)
+++ trunk/ui/tree/src/test/java/org/richfaces/converter/BaseTreeConverterTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,196 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.converter;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class BaseTreeConverterTest extends AbstractAjax4JsfTestCase {
+
+ private static class BaseTreeConverterImpl extends BaseTreeConverter {
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ return null;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ return null;
+ }
+
+ };
+
+ public BaseTreeConverterTest(String name) {
+ super(name);
+ }
+
+ public void testAppendToKeyString() throws Exception {
+ BaseTreeConverterImpl converter = new BaseTreeConverterImpl();
+ StringBuilder sb = new StringBuilder();
+
+ converter.appendToKeyString(sb, "_a_b_");
+
+ assertEquals("__a__b__:", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, ":a:b:");
+ assertEquals("_:a_:b_::", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, "test");
+ assertEquals("test:", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, "a\u0009b");
+ assertEquals("a_x09b:", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, "a\u00a0c");
+ assertEquals("a_xa0c:", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, "a\u037ec");
+ assertEquals("a_037ec:", sb.toString());
+ sb.setLength(0);
+
+ converter.appendToKeyString(sb, "a\ue1acd");
+ assertEquals("a_e1acd:", sb.toString());
+ sb.setLength(0);
+ }
+
+ public void testSplitKeyString() throws Exception {
+ BaseTreeConverterImpl converter = new BaseTreeConverterImpl();
+ List<String> split;
+
+ split = converter.splitKeyString("__a__b__:c");
+ assertEquals(2, split.size());
+ assertEquals("_a_b_", split.get(0));
+ assertEquals("c", split.get(1));
+
+ split = converter.splitKeyString("c:__a__");
+ assertEquals(2, split.size());
+ assertEquals("c", split.get(0));
+ assertEquals("_a_", split.get(1));
+
+ split = converter.splitKeyString("_:a_::b");
+ assertEquals(2, split.size());
+ assertEquals(":a:", split.get(0));
+ assertEquals("b", split.get(1));
+
+ split = converter.splitKeyString("b:_:a_:");
+ assertEquals(2, split.size());
+ assertEquals("b", split.get(0));
+ assertEquals(":a:", split.get(1));
+
+ split = converter.splitKeyString("_x09:c_x08ab");
+ assertEquals(2, split.size());
+ assertEquals("\u0009", split.get(0));
+ assertEquals("c\u0008ab", split.get(1));
+
+ split = converter.splitKeyString("c_x08ab:_x09");
+ assertEquals(2, split.size());
+ assertEquals("c\u0008ab", split.get(0));
+ assertEquals("\u0009", split.get(1));
+
+ split = converter.splitKeyString("_xa9:c_x98ab");
+ assertEquals(2, split.size());
+ assertEquals("\u00a9", split.get(0));
+ assertEquals("c\u0098ab", split.get(1));
+
+ split = converter.splitKeyString("_0008:a_0009bcd");
+ assertEquals(2, split.size());
+ assertEquals("\u0008", split.get(0));
+ assertEquals("a\u0009bcd", split.get(1));
+
+ split = converter.splitKeyString("_0028:a_00a9bcd");
+ assertEquals(2, split.size());
+ assertEquals("\u0028", split.get(0));
+ assertEquals("a\u00a9bcd", split.get(1));
+
+ split = converter.splitKeyString("_0a28:a_0ea9bcd");
+ assertEquals(2, split.size());
+ assertEquals("\u0a28", split.get(0));
+ assertEquals("a\u0ea9bcd", split.get(1));
+
+ split = converter.splitKeyString("_9e28:a_f3a9bcd");
+ assertEquals(2, split.size());
+ assertEquals("\u9e28", split.get(0));
+ assertEquals("a\uf3a9bcd", split.get(1));
+
+ split = converter.splitKeyString("");
+ assertEquals(0, split.size());
+
+ try {
+ converter.splitKeyString("_3");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ converter.splitKeyString("_30");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ converter.splitKeyString("_x3");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ converter.splitKeyString("_x3q");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ converter.splitKeyString("_234");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ converter.splitKeyString("_f3eq");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+}
+
+
Added: trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverterTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverterTest.java (rev 0)
+++ trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorIntegerRowKeyConverterTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,104 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.converter;
+
+import java.util.Arrays;
+
+import javax.faces.component.UIComponent;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UITree;
+import org.richfaces.model.ListRowKey;
+import org.richfaces.model.StackingTreeModelKey;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class TreeAdaptorIntegerRowKeyConverterTest extends AbstractAjax4JsfTestCase {
+
+ private UIComponent tree;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ this.tree = facesContext.getApplication().createComponent(UITree.COMPONENT_TYPE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ this.tree = null;
+ }
+
+
+ public TreeAdaptorIntegerRowKeyConverterTest(String name) {
+ super(name);
+ }
+
+ public void testCreateConverter() throws Exception {
+ Converter converter = facesContext.getApplication().createConverter(TreeAdaptorIntegerRowKeyConverter.CONVERTER_ID);
+ assertNotNull(converter);
+ }
+
+ public void testGetAsString() throws Exception {
+ Converter converter = new TreeAdaptorIntegerRowKeyConverter();
+
+ Object key = new ListRowKey<StackingTreeModelKey<Integer>>(Arrays.asList(
+ new StackingTreeModelKey<Integer>("list", Integer.valueOf(12)),
+ new StackingTreeModelKey<Integer>("map", Integer.valueOf(456)),
+ new StackingTreeModelKey<Integer>("custom", Integer.valueOf(789))
+ ));
+
+ String string = converter.getAsString(facesContext, tree, key);
+ assertEquals("list:12:map:456:custom:789:", string);
+
+ string = converter.getAsString(facesContext, tree, null);
+ assertNull(string);
+ }
+
+ public void testGetAsObject() throws Exception {
+ Converter converter = new TreeAdaptorIntegerRowKeyConverter();
+ ListRowKey<StackingTreeModelKey<Integer>> key = (ListRowKey<StackingTreeModelKey<Integer>>)
+ converter.getAsObject(facesContext, tree, "map:123:anotherMap:456:m:789");
+ StackingTreeModelKey stackingModelKey;
+
+ assertEquals(3, key.depth());
+
+ stackingModelKey = key.get(0);
+ assertEquals("map", stackingModelKey.getModelId());
+ assertEquals(Integer.valueOf(123), stackingModelKey.getModelKey());
+
+ stackingModelKey = key.get(1);
+ assertEquals("anotherMap", stackingModelKey.getModelId());
+ assertEquals(Integer.valueOf(456), stackingModelKey.getModelKey());
+
+ stackingModelKey = key.get(2);
+ assertEquals("m", stackingModelKey.getModelId());
+ assertEquals(Integer.valueOf(789), stackingModelKey.getModelKey());
+ }
+
+}
Added: trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorRowKeyConverterTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorRowKeyConverterTest.java (rev 0)
+++ trunk/ui/tree/src/test/java/org/richfaces/converter/TreeAdaptorRowKeyConverterTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,160 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.converter;
+
+import java.util.Arrays;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UITree;
+import org.richfaces.model.ListRowKey;
+import org.richfaces.model.StackingTreeModelKey;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class TreeAdaptorRowKeyConverterTest extends AbstractAjax4JsfTestCase {
+
+ private UIComponent tree;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ this.tree = facesContext.getApplication().createComponent(UITree.COMPONENT_TYPE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ this.tree = null;
+ }
+
+
+ public TreeAdaptorRowKeyConverterTest(String name) {
+ super(name);
+ }
+
+ public void testCreateConverter() throws Exception {
+ Converter converter = facesContext.getApplication().createConverter(TreeAdaptorRowKeyConverter.CONVERTER_ID);
+ assertNotNull(converter);
+ }
+
+ public void testGetAsString() throws Exception {
+ Converter converter = new TreeAdaptorRowKeyConverter();
+
+ Object key = new ListRowKey<StackingTreeModelKey<Object>>(Arrays.asList(
+ new StackingTreeModelKey<Object>("list", Integer.valueOf(12)),
+ new StackingTreeModelKey<Object>("map", "key"),
+ new StackingTreeModelKey<Object>("custom", Long.valueOf(456))
+ ));
+
+ String string = converter.getAsString(facesContext, tree, key);
+ assertEquals("list:12:map:key:custom:456:", string);
+
+ string = converter.getAsString(facesContext, tree, null);
+ assertNull(string);
+ }
+
+ public void testGetAsObject() throws Exception {
+ Converter converter = new TreeAdaptorRowKeyConverter();
+ ListRowKey<StackingTreeModelKey<Object>> key = (ListRowKey<StackingTreeModelKey<Object>>)
+ converter.getAsObject(facesContext, tree, "map:key1:anotherMap:itsKey:m:key_x32");
+ StackingTreeModelKey stackingModelKey;
+
+ assertEquals(3, key.depth());
+
+ stackingModelKey = key.get(0);
+ assertEquals("map", stackingModelKey.getModelId());
+ assertEquals("key1", stackingModelKey.getModelKey());
+
+ stackingModelKey = key.get(1);
+ assertEquals("anotherMap", stackingModelKey.getModelId());
+ assertEquals("itsKey", stackingModelKey.getModelKey());
+
+ stackingModelKey = key.get(2);
+ assertEquals("m", stackingModelKey.getModelId());
+ assertEquals("key2", stackingModelKey.getModelKey());
+
+ Object object = converter.getAsObject(facesContext, tree, null);
+ assertNull(object);
+
+ object = converter.getAsObject(facesContext, tree, "");
+ assertNull(object);
+ }
+
+ public void testThrows() throws Exception {
+ Converter converter = new TreeAdaptorRowKeyConverter();
+ try {
+ converter.getAsObject(null, tree, "model:value");
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsObject(facesContext, null, "model:value");
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsString(null, tree, new ListRowKey<StackingTreeModelKey<String>>(null, new StackingTreeModelKey<String>("a", "b")));
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsString(facesContext, null, new ListRowKey<StackingTreeModelKey<String>>(null, new StackingTreeModelKey<String>("a", "b")));
+ fail();
+ } catch (NullPointerException e) {
+ }
+
+ try {
+ converter.getAsObject(facesContext, tree, "a:b:c_d");
+ fail();
+ } catch (ConverterException e) {
+ FacesMessage message = e.getFacesMessage();
+ System.out.println(message.getSummary());
+ }
+
+ converter = new TreeAdaptorRowKeyConverter() {
+ @Override
+ protected String convertModelKeyToString(FacesContext context,
+ UIComponent component, String modelId, Object value) {
+ return Double.toString((Double) value);
+ }
+ };
+
+ try {
+ converter.getAsString(facesContext, tree, new ListRowKey<StackingTreeModelKey<Object>>(null, new StackingTreeModelKey<Object>("a", "b")));
+ fail();
+ } catch (ConverterException e) {
+ FacesMessage message = e.getFacesMessage();
+ System.out.println(message.getSummary());
+ }
+ }
+}
Added: trunk/ui/tree/src/test/java/org/richfaces/converter/TreeRowKeyConverterTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/converter/TreeRowKeyConverterTest.java (rev 0)
+++ trunk/ui/tree/src/test/java/org/richfaces/converter/TreeRowKeyConverterTest.java 2009-03-18 20:11:48 UTC (rev 13014)
@@ -0,0 +1,181 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.converter;
+
+import java.util.Arrays;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UITree;
+import org.richfaces.model.ListRowKey;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class TreeRowKeyConverterTest extends AbstractAjax4JsfTestCase {
+
+ private UIComponent tree;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ this.tree = facesContext.getApplication().createComponent(UITree.COMPONENT_TYPE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ this.tree = null;
+ }
+
+ public TreeRowKeyConverterTest(String name) {
+ super(name);
+ }
+
+ public void testCreateConverter() throws Exception {
+ Converter converter = facesContext.getApplication().createConverter(TreeRowKeyConverter.CONVERTER_ID);
+ assertNotNull(converter);
+ }
+
+ public void testGetAsString() throws Exception {
+ Converter converter = new TreeRowKeyConverter();
+
+ ListRowKey key = new ListRowKey(Arrays.asList("test", Long.valueOf(456), Integer.valueOf(123)));
+
+ String string = converter.getAsString(facesContext, tree, key);
+ assertEquals("test:456:123:", string);
+
+ string = converter.getAsString(facesContext, tree, null);
+ assertNull(string);
+ }
+
+ public void testGetAsObject() throws Exception {
+ Converter converter = new TreeRowKeyConverter();
+ ListRowKey<String> listRowKey = (ListRowKey<String>) converter.getAsObject(facesContext, tree, "test:test__2:test_:3");
+
+ assertEquals(3, listRowKey.depth());
+ assertEquals("test", listRowKey.get(0));
+ assertEquals("test_2", listRowKey.get(1));
+ assertEquals("test:3", listRowKey.get(2));
+
+ Object convertedKey = converter.getAsObject(facesContext, tree, null);
+ assertNull(convertedKey);
+
+ convertedKey = converter.getAsObject(facesContext, tree, "");
+ assertNull(convertedKey);
+ }
+
+ private static final class TreeRowKeyIntegerHexConverter extends TreeRowKeyConverter {
+ @Override
+ protected String convertKeyToString(FacesContext context,
+ UIComponent component, Object value) {
+
+ return Integer.toHexString((Integer) value);
+ }
+
+ @Override
+ protected Object convertStringToKey(FacesContext context,
+ UIComponent component, String value) {
+
+ return Integer.parseInt(value, 16);
+ }
+ };
+
+ public void testGetAsStringHexConversion() throws Exception {
+ Converter converter = new TreeRowKeyIntegerHexConverter();
+
+ Object key = new ListRowKey<Integer>(Arrays.asList(Integer.valueOf(0x33), Integer.valueOf(0x4512),
+ Integer.valueOf(0xfed0)));
+
+ String string = converter.getAsString(facesContext, tree, key);
+ assertEquals("33:4512:fed0:", string);
+ }
+
+ public void testGetAsObjectHexConversion() throws Exception {
+ Converter converter = new TreeRowKeyIntegerHexConverter();
+
+ ListRowKey<Integer> key = (ListRowKey<Integer>) converter.getAsObject(facesContext, tree, "45:678:fabc");
+
+ assertEquals(3, key.depth());
+ assertEquals(Integer.valueOf(0x45), key.get(0));
+ assertEquals(Integer.valueOf(0x678), key.get(1));
+ assertEquals(Integer.valueOf(0xfabc), key.get(2));
+ }
+
+ public void testThrows() throws Exception {
+ Converter converter = new TreeRowKeyConverter();
+ try {
+ converter.getAsObject(null, tree, "model:value");
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsObject(facesContext, null, "model:value");
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsString(null, tree, new ListRowKey<String>(null, "a"));
+ fail();
+ } catch (NullPointerException e) {
+ }
+ try {
+ converter.getAsString(facesContext, null, new ListRowKey<String>(null, "a"));
+ fail();
+ } catch (NullPointerException e) {
+ }
+
+ try {
+ converter.getAsObject(facesContext, tree, "_x");
+ fail();
+ } catch (ConverterException e) {
+ FacesMessage message = e.getFacesMessage();
+ System.out.println(message.getSummary());
+ }
+
+ converter = new TreeRowKeyConverter() {
+ @Override
+ protected String convertKeyToString(FacesContext context,
+ UIComponent component, Object value) {
+
+ return Double.toString((Double) value);
+ }
+ };
+
+ try {
+ converter.getAsString(facesContext, tree, new ListRowKey<Object>(null, "abc"));
+ fail();
+ } catch (ConverterException e) {
+ FacesMessage message = e.getFacesMessage();
+ System.out.println(message.getSummary());
+ }
+ }
+}
15 years, 10 months
JBoss Rich Faces SVN: r13013 - in trunk/framework: api/src/main/java/org/richfaces/model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-18 16:10:19 -0400 (Wed, 18 Mar 2009)
New Revision: 13013
Added:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4351
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -324,6 +324,7 @@
public static final String INVALID_VALUE = "INVALID_VALUE";
public static final String DATASCROLLER_PAGE_MISSING = "DATASCROLLER_PAGE_MISSING";
public static final String DATASCROLLER_PAGES_DIFFERENT = "DATASCROLLER_PAGES_DIFFERENT";
+ public static final String COMPONENT_CONVERSION_ERROR = "COMPONENT_CONVERSION_ERROR";
public static void main(String[] args) {
String m = getMessage(INVALID_ATTRIBUTE_VALUE, "A", "B");
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -105,16 +105,6 @@
this.path = new ArrayList<T>(list);
}
-
- /**
- * Path object constructor
- * @param path first path segment
- */
- public ListRowKey(T path) {
- super();
- this.path = new ArrayList<T>(1);
- this.path.add(path);
- }
public int depth() {
return path.size();
@@ -190,19 +180,8 @@
boolean hasNext = iterator.hasNext();
while (hasNext) {
- T segment = iterator.next();
- if (segment instanceof CompositeKey) {
- CompositeKey compositeKey = (CompositeKey) segment;
- Iterator keySegments = compositeKey.getKeySegments();
- while (keySegments.hasNext()) {
- appendSegment(result, keySegments.next().toString());
- if (keySegments.hasNext()) {
- result.append(AbstractTreeDataModel.SEPARATOR);
- }
- }
- } else {
- appendSegment(result, segment.toString());
- }
+ T segment = iterator.next();
+ appendSegment(result, segment.toString());
hasNext = iterator.hasNext();
@@ -243,10 +222,6 @@
return split;
}
- public static interface CompositeKey {
- public Iterator getKeySegments();
- }
-
public static void main(String[] args) {
System.out.println(Arrays.toString(fromString("test_:abc:123:a__b")));
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -21,14 +21,12 @@
package org.richfaces.model;
import java.io.IOException;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.NoSuchElementException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -39,7 +37,6 @@
import org.ajax4jsf.model.Range;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
-import org.richfaces.model.ListRowKey.CompositeKey;
import org.w3c.dom.NamedNodeMap;
/**
@@ -141,7 +138,7 @@
}
}
- protected StackingTreeModel doSetupKey(Iterator<Key> keyIterator, Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
+ protected StackingTreeModel doSetupKey(Iterator<StackingTreeModelKey> keyIterator, Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
if (modelKey != null) {
if (!setupModel(modelKey, context)) {
//no key is available
@@ -153,7 +150,7 @@
}
if (keyIterator != null && keyIterator.hasNext()) {
- Key key = keyIterator.next();
+ StackingTreeModelKey key = keyIterator.next();
StackingTreeModel stackingTreeModel = this.getInternalModelById(key.modelId);
Iterator<StackEntry> nextEntriesIterator = null;
Object nextModelKey = key.modelKey;
@@ -186,9 +183,9 @@
return (stackEntries.getLast()).model;
}
} else {
- Iterator<Key> keyIterator = null;
+ Iterator<StackingTreeModelKey> keyIterator = null;
if (key != null) {
- keyIterator = ((ListRowKey<Key>) key).iterator();
+ keyIterator = ((ListRowKey<StackingTreeModelKey>) key).iterator();
}
StackingTreeModel model = doSetupKey(keyIterator, stackEntries.iterator(), context, null);
@@ -401,7 +398,7 @@
throws IOException {
Argument a = (Argument) argument;
- ListRowKey listRowKey = new ListRowKey(a.listRowKey, new Key(
+ ListRowKey listRowKey = new ListRowKey(a.listRowKey, new StackingTreeModelKey(
a.model.id, rowKey));
//System.out.println(".walk() " + (theLast ? " * " : "") + listRowKey);
@@ -527,158 +524,6 @@
return parent;
}
- /**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- */
- protected static class Key implements Serializable, CompositeKey {
- /**
- *
- */
- private static final long serialVersionUID = -6821854350257816571L;
- protected Object modelKey;
- protected String modelId;
-
- public Key(String modelId, Object modelKey) {
- super();
- this.modelId = modelId;
- this.modelKey = modelKey;
- }
-
- public String toString() {
- return this.modelId + ":" + this.modelKey;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((modelId == null) ? 0 : modelId.hashCode());
- result = prime * result
- + ((modelKey == null) ? 0 : modelKey.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final Key other = (Key) obj;
- if (modelId == null) {
- if (other.modelId != null)
- return false;
- } else if (!modelId.equals(other.modelId))
- return false;
- if (modelKey == null) {
- if (other.modelKey != null)
- return false;
- } else if (!modelKey.equals(other.modelKey))
- return false;
- return true;
- }
-
- static enum IteratorState {
- INITIAL {
- @Override
- protected boolean hasNext(Key arg0) {
- return true;
- }
-
- @Override
- protected Object next(Key arg0) {
- throw new IllegalStateException();
- }
-
- @Override
- protected IteratorState nextState() {
- return ID;
- }
- },
-
- ID {
- @Override
- protected boolean hasNext(Key arg0) {
- return true;
- }
-
- @Override
- protected Object next(Key arg0) {
- return arg0.modelId;
- }
-
- @Override
- protected IteratorState nextState() {
- return KEY;
- }
- },
-
- KEY {
- @Override
- protected boolean hasNext(Key arg0) {
- return false;
- }
-
- @Override
- protected Object next(Key arg0) {
- return arg0.modelKey;
- }
-
- @Override
- protected IteratorState nextState() {
- return DONE;
- }
- },
-
- DONE {
- @Override
- protected boolean hasNext(Key arg0) {
- return false;
- }
-
- @Override
- protected Object next(Key arg0) {
- throw new NoSuchElementException();
- }
-
- @Override
- protected IteratorState nextState() {
- return DONE;
- }
- };
-
- protected abstract boolean hasNext(Key key);
-
- protected abstract Object next(Key key);
-
- protected abstract IteratorState nextState();
- };
-
- public Iterator getKeySegments() {
-
- return new Iterator<Object>() {
- IteratorState state = IteratorState.INITIAL;
-
- public boolean hasNext() {
- return state.hasNext(Key.this);
- }
-
- public Object next() {
- state = state.nextState();
- return state.next(Key.this);
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- };
- }
- }
-
protected boolean isActiveData() {
return true;
}
@@ -733,7 +578,7 @@
return null;
}
- list.add(new Key(modelId, key));
+ list.add(new StackingTreeModelKey(modelId, key));
if (!model.setupModel(key, context) || !model.isActiveData()) {
return null;
Added: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.model;
+
+import java.io.Serializable;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ */
+public class StackingTreeModelKey<T> implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6821854350257816571L;
+ protected T modelKey;
+ protected String modelId;
+
+ public StackingTreeModelKey(String modelId, T modelKey) {
+ super();
+ this.modelId = modelId;
+ this.modelKey = modelKey;
+ }
+
+ public String toString() {
+ return this.modelId + AbstractTreeDataModel.SEPARATOR + this.modelKey;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((modelId == null) ? 0 : modelId.hashCode());
+ result = prime * result
+ + ((modelKey == null) ? 0 : modelKey.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final StackingTreeModelKey other = (StackingTreeModelKey) obj;
+ if (modelId == null) {
+ if (other.modelId != null)
+ return false;
+ } else if (!modelId.equals(other.modelId))
+ return false;
+ if (modelKey == null) {
+ if (other.modelKey != null)
+ return false;
+ } else if (!modelKey.equals(other.modelKey))
+ return false;
+ return true;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public Object getModelKey() {
+ return modelKey;
+ }
+}
\ No newline at end of file
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -150,13 +150,7 @@
boolean isLast = nextChildNode == null;
- ListRowKey newRowKey;
- if (rowKey != null) {
- newRowKey = new ListRowKey(listRowKey, identifier);
- } else {
- newRowKey = new ListRowKey(identifier);
- }
-
+ ListRowKey newRowKey = new ListRowKey(listRowKey, identifier);
this.doWalk(context, dataVisitor, range, newRowKey, argument, isLast);
}
Modified: trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties 2009-03-18 20:10:19 UTC (rev 13013)
@@ -257,4 +257,5 @@
HIGHLIGHT_LIBRARY_NOT_FOUND="In order to use highlight attribute of the rich:insert component, add jhighlight.jar from https://jhighlight.dev.java.net/ into application."
INVALID_VALUE="Component {0} has invalid value expression {1}"
DATASCROLLER_PAGE_MISSING=Datascroller {0}: The requested page #{1} isn''t found in the model containing {2} pages. Paging is reset to page #{3}
-DATASCROLLER_PAGES_DIFFERENT=Datascroller components attached to component: {0} have different values of ''page'' attribute : {1}
\ No newline at end of file
+DATASCROLLER_PAGES_DIFFERENT=Datascroller components attached to component\: {0} have different values of ''page'' attribute \: {1}
+COMPONENT_CONVERSION_ERROR=Component {0}: conversion error occurred for value {1}
\ No newline at end of file
Modified: trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -29,7 +29,6 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.model.StackingTreeModel.Key;
import org.richfaces.model.entity.Directory;
import org.richfaces.model.entity.File;
import org.richfaces.model.entity.Named;
@@ -156,14 +155,14 @@
public void testBadKey() throws Exception {
StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModel.Key("project", "projectA")));
+ this.stackingTreeModel.setRowKey(new ListRowKey(null, new StackingTreeModelKey("project", "projectA")));
assertTrue(this.stackingTreeModel.isRowAvailable());
assertNotNull(this.stackingTreeModel.getRowData());
assertNull(this.stackingTreeModel.getTreeNode());
assertFalse(this.stackingTreeModel.isLeaf());
- this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModel.Key("project", "projectAAAAA")));
+ this.stackingTreeModel.setRowKey(new ListRowKey(null, new StackingTreeModelKey("project", "projectAAAAA")));
assertFalse(this.stackingTreeModel.isRowAvailable());
try {
Object rowData = this.stackingTreeModel.getRowData();
@@ -220,12 +219,12 @@
}
public void testKey() throws Exception {
- Key key = new Key("aaa", new Integer(10));
- Key key2 = new Key("aaa", new Integer(11));
- Key key3 = new Key("aaa", new Integer(10));
- Key key4 = new Key("bbb", new Integer(10));
+ StackingTreeModelKey key = new StackingTreeModelKey("aaa", new Integer(10));
+ StackingTreeModelKey key2 = new StackingTreeModelKey("aaa", new Integer(11));
+ StackingTreeModelKey key3 = new StackingTreeModelKey("aaa", new Integer(10));
+ StackingTreeModelKey key4 = new StackingTreeModelKey("bbb", new Integer(10));
- assertFalse(key.equals(new Key("aaa", new Integer(0)) {} ));
+ assertFalse(key.equals(new StackingTreeModelKey("aaa", new Integer(0)) {} ));
assertTrue(key.equals(key3));
assertTrue(key3.equals(key));
@@ -259,10 +258,10 @@
assertFalse(key2.equals(key4));
assertFalse(key3.equals(key4));
- assertFalse(new Key("aaa", new Integer(10)).equals(null));
- assertFalse(new Key("aaa", null).equals(null));
- assertFalse(new Key(null, new Integer(10)).equals(null));
- assertFalse(new Key(null, null).equals(null));
+ assertFalse(new StackingTreeModelKey("aaa", new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(null));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey(null, null).equals(null));
assertFalse(key.hashCode() == key4.hashCode());
assertFalse(key2.hashCode() == key4.hashCode());
@@ -273,21 +272,21 @@
assertFalse(key3.hashCode() == 0);
assertFalse(key4.hashCode() == 0);
- assertTrue(new Key(null, new Integer(11)).equals(new Key(null, new Integer(11))));
- assertFalse(new Key(null, new Integer(10)).equals(new Key(null, new Integer(11))));
- assertFalse(new Key(null, new Integer(10)).equals(new Key("aaa", new Integer(10))));
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).equals(new StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey("aaa", new Integer(10))));
- assertTrue(new Key(null, new Integer(11)).hashCode() == new Key(null, new Integer(11)).hashCode());
- assertFalse(new Key(null, new Integer(10)).hashCode() == new Key(null, new Integer(11)).hashCode());
- assertFalse(new Key(null, new Integer(10)).hashCode() == new Key("aaa", new Integer(10)).hashCode());
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
- assertTrue(new Key("aaa", null).equals(new Key("aaa", null)));
- assertFalse(new Key("aaa", null).equals(new Key("bbb", null)));
- assertFalse(new Key("aaa", null).equals(new Key("aaa", new Integer(10))));
+ assertTrue(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("bbb", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", new Integer(10))));
- assertTrue(new Key("aaa", null).hashCode() == new Key("aaa", null).hashCode());
- assertFalse(new Key("aaa", null).hashCode() == new Key("bbb", null).hashCode());
- assertFalse(new Key("aaa", null).hashCode() == new Key("aaa", new Integer(10)).hashCode());
+ assertTrue(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("bbb", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
}
class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
@@ -301,7 +300,7 @@
StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
- stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ stackingTreeModel.walk(context, visitor2, null, new ListRowKey(null, new StackingTreeModelKey("project", "projectA")),
argument, false);
assertEquals(5, visitor2.getCounter());
@@ -318,7 +317,7 @@
return false;
}
- }, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project", "projectA")),
argument, false);
assertEquals(0, visitor20.getCounter());
@@ -335,14 +334,14 @@
return true;
}
- }, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project", "projectA")),
argument, false);
assertEquals(1, visitor21.getCounter());
StackingTreeDataModelTestVisitor2 visitor22 = new StackingTreeDataModelTestVisitor2();
- stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new StackingTreeModel.Key("project", "projectB")),
+ stackingTreeModel.walk(context, visitor22, null, new ListRowKey(null, new StackingTreeModelKey("project", "projectB")),
argument, false);
assertEquals(4, visitor22.getCounter());
@@ -363,7 +362,7 @@
return true;
}
- }, new ListRowKey(new StackingTreeModel.Key("project", "projectB")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project", "projectB")),
argument, false);
assertEquals(4, visitor23.getCounter());
Modified: trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java 2009-03-18 19:56:12 UTC (rev 13012)
+++ trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java 2009-03-18 20:10:19 UTC (rev 13013)
@@ -21,20 +21,12 @@
package org.richfaces.model;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.UUID;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.model.ListRowKey.CompositeKey;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski
* @since 3.3.0
@@ -96,83 +88,76 @@
}
public void testConvertKey() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:17", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey = (ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:17", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals(Long.valueOf(17), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals(Long.valueOf(17), key.getModelKey());
assertFalse(iterator.hasNext());
}
public void testConvertKey1() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:9", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey = (ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:9", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals("9", keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals("9", key.getModelKey());
assertFalse(iterator.hasNext());
}
public void testConvertKey2() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:abc", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey = (ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:abc", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals("abc", keySegments.next().toString());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals("abc", key.getModelKey().toString());
assertFalse(iterator.hasNext());
}
public void testConvertKey3() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>) model.convertToKey(facesContext, "mapsModel:0", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey = (ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext, "mapsModel:0", null, null);
assertEquals(1, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(0), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(0), key.getModelKey());
assertFalse(iterator.hasNext());
}
15 years, 10 months
JBoss Rich Faces SVN: r13012 - in trunk/samples/functions-demo/src/main/webapp: WEB-INF and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-18 15:56:12 -0400 (Wed, 18 Mar 2009)
New Revision: 13012
Added:
trunk/samples/functions-demo/src/main/webapp/pages/error.html
trunk/samples/functions-demo/src/main/webapp/pages/login.html
Modified:
trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml
trunk/samples/functions-demo/src/main/webapp/index.jsp
trunk/samples/functions-demo/src/main/webapp/pages/index.jsp
trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-6551
Modified: trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml 2009-03-18 19:56:01 UTC (rev 13011)
+++ trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml 2009-03-18 19:56:12 UTC (rev 13012)
@@ -1,61 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <display-name>Archetype Created Web Application</display-name>
- <context-param>
- <param-name>javax.faces.CONFIG_FILES</param-name>
- <param-value>/WEB-INF/faces-config.xml</param-value>
- </context-param>
- <context-param>
- <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
- <param-value>server</param-value>
- </context-param>
- <!-- Use Documents Saved as *.xhtml -->
- <context-param>
- <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
- <param-value>.jsp</param-value>
- </context-param>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Archetype Created Web Application</display-name>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <!-- Use Documents Saved as *.xhtml -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jsp</param-value>
+ </context-param>
- <!-- Facelets pages will use the .xhtml extension -->
- <context-param>
- <param-name>facelets.VIEW_MAPPINGS</param-name>
- <param-value>*xhtml</param-value>
- </context-param>
-
- <context-param>
- <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
- <param-value>com.sun.facelets.FaceletViewHandler</param-value>
- </context-param>
+ <!-- Facelets pages will use the .xhtml extension -->
+ <context-param>
+ <param-name>facelets.VIEW_MAPPINGS</param-name>
+ <param-value>*xhtml</param-value>
+ </context-param>
- <!--
- -->
- <filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>ajax4jsf</filter-name>
- <servlet-name>Faces Servlet</servlet-name>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- <dispatcher>ERROR</dispatcher>
- </filter-mapping>
- <!-- Faces Servlet -->
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- </servlet>
-
- <!-- Use prefix mapping for Facelets pages, e.g. http://localhost:8080/webapp/faces/mypage.xhtml -->
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
- </servlet-mapping>
+ <context-param>
+ <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+ <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- </login-config>
+ <!--
+ -->
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ </servlet>
+
+ <!--
+ Use prefix mapping for Facelets pages, e.g.
+ http://localhost:8080/webapp/faces/mypage.xhtml
+ -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces-auth/*</url-pattern>
+ </servlet-mapping>
+
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/pages/login.html</form-login-page>
+ <form-error-page>/pages/error.html</form-error-page>
+ </form-login-config>
+ </login-config>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>faces-auth</web-resource-name>
+ <url-pattern>/faces-auth/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>user</role-name>
+ <role-name>admin</role-name>
+ </auth-constraint>
+ </security-constraint>
</web-app>
Modified: trunk/samples/functions-demo/src/main/webapp/index.jsp
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/index.jsp 2009-03-18 19:56:01 UTC (rev 13011)
+++ trunk/samples/functions-demo/src/main/webapp/index.jsp 2009-03-18 19:56:12 UTC (rev 13012)
@@ -6,7 +6,9 @@
<body>
<a href="faces/pages/index.jsp">JSP</a><br/>
- <a href="faces/pages/index.xhtml">Facelets</a>
+ <a href="faces-auth/pages/index.jsp">JSP authenticated</a><br/>
+ <a href="faces/pages/index.xhtml">Facelets</a><br />
+ <a href="faces-auth/pages/index.xhtml">Facelets authenticated</a>
</body>
</html>
\ No newline at end of file
Added: trunk/samples/functions-demo/src/main/webapp/pages/error.html
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/error.html (rev 0)
+++ trunk/samples/functions-demo/src/main/webapp/pages/error.html 2009-03-18 19:56:12 UTC (rev 13012)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Login failed</title>
+</head>
+<body>
+Login failed
+</body>
+</html>
\ No newline at end of file
Modified: trunk/samples/functions-demo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/index.jsp 2009-03-18 19:56:01 UTC (rev 13011)
+++ trunk/samples/functions-demo/src/main/webapp/pages/index.jsp 2009-03-18 19:56:12 UTC (rev 13012)
@@ -21,6 +21,16 @@
<br />
<h:outputText value="#{fn:findComponent('input').value}" />
<br />
+
+ Roles:
+ <h:outputText rendered="#{fn:isUserInRole('admin, user')}" value="admin/user" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('admin')}" value="admin" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('user')}" value="user" />
+ <br />
+
+
</f:view>
</body>
</html>
Modified: trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml 2009-03-18 19:56:01 UTC (rev 13011)
+++ trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml 2009-03-18 19:56:12 UTC (rev 13012)
@@ -20,5 +20,14 @@
<br />
<h:outputText value="#{fn:findComponent('input').value}" />
<br />
+
+ Roles:
+ <h:outputText rendered="#{fn:isUserInRole('admin, user')}" value="admin/user" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('admin')}" value="admin" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('user')}" value="user" />
+ <br />
+
</f:view>
</html>
\ No newline at end of file
Added: trunk/samples/functions-demo/src/main/webapp/pages/login.html
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/login.html (rev 0)
+++ trunk/samples/functions-demo/src/main/webapp/pages/login.html 2009-03-18 19:56:12 UTC (rev 13012)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Insert title here</title>
+</head>
+<body>
+ <form action="j_security_check" method="post">
+ <input type="text" name="j_username" />
+ <br />
+ <input type="password" name="j_password" />
+ <br />
+ <input type="submit" value="Login" />
+ </form>
+</body>
+</html>
\ No newline at end of file
15 years, 10 months
JBoss Rich Faces SVN: r13011 - in trunk/ui/functions/src/main: java/org/richfaces/function and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-18 15:56:01 -0400 (Wed, 18 Mar 2009)
New Revision: 13011
Modified:
trunk/ui/functions/src/main/config/component/functions.xml
trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
Log:
https://jira.jboss.org/jira/browse/RF-6551
Modified: trunk/ui/functions/src/main/config/component/functions.xml
===================================================================
--- trunk/ui/functions/src/main/config/component/functions.xml 2009-03-18 17:49:15 UTC (rev 13010)
+++ trunk/ui/functions/src/main/config/component/functions.xml 2009-03-18 19:56:01 UTC (rev 13011)
@@ -23,4 +23,9 @@
<name>findComponent</name>
<method>org.richfaces.function.RichFunction.findComponent(String)</method>
</function>
+
+ <function>
+ <name>isUserInRole</name>
+ <method>org.richfaces.function.RichFunction.isUserInRole(Object)</method>
+ </function>
</components>
Modified: trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
===================================================================
--- trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java 2009-03-18 17:49:15 UTC (rev 13010)
+++ trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java 2009-03-18 19:56:01 UTC (rev 13011)
@@ -21,10 +21,14 @@
package org.richfaces.function;
+import java.util.Set;
+
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
/**
@@ -80,4 +84,25 @@
public static UIComponent findComponent(String id) {
return findComponent(FacesContext.getCurrentInstance(), id);
}
+
+ /**
+ * @since 3.3.1
+ * @param rolesObject
+ * @return
+ */
+ public static boolean isUserInRole(Object rolesObject) {
+ Set<String> rolesSet = AjaxRendererUtils.asSet(rolesObject);
+ if (rolesSet != null) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+
+ for (String role : rolesSet) {
+ if (externalContext.isUserInRole(role)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
}
15 years, 10 months
JBoss Rich Faces SVN: r13010 - trunk/samples/colorPickerDemo.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2009-03-18 13:49:15 -0400 (Wed, 18 Mar 2009)
New Revision: 13010
Modified:
trunk/samples/colorPickerDemo/pom.xml
Log:
colorPicker: dependency was changed to richfaces.core
Modified: trunk/samples/colorPickerDemo/pom.xml
===================================================================
--- trunk/samples/colorPickerDemo/pom.xml 2009-03-18 17:14:38 UTC (rev 13009)
+++ trunk/samples/colorPickerDemo/pom.xml 2009-03-18 17:49:15 UTC (rev 13010)
@@ -1,47 +1,47 @@
-<?xml version="1.0"?><project>
- <parent>
- <artifactId>samples</artifactId>
- <groupId>org.richfaces</groupId>
- <version>3.3.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.samples</groupId>
- <artifactId>colorPickerDemo</artifactId>
- <packaging>war</packaging>
- <name>colorPicker Maven Webapp</name>
- <build>
- <finalName>colorPickerDemo</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui</groupId>
- <artifactId>richfaces-ui</artifactId>
- <version>3.3.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>richfaces-impl</artifactId>
- <version>3.3.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui</groupId>
- <artifactId>colorPicker</artifactId>
- <version>3.3.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.3.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>colorPickerDemo</artifactId>
+ <packaging>war</packaging>
+ <name>colorPicker Maven Webapp</name>
+ <build>
+ <finalName>colorPickerDemo</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>core</artifactId>
+ <version>3.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>colorPicker</artifactId>
+ <version>3.3.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
15 years, 10 months
JBoss Rich Faces SVN: r13009 - trunk/ui/calendar/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2009-03-18 13:14:38 -0400 (Wed, 18 Mar 2009)
New Revision: 13009
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
Log:
https://jira.jboss.org/jira/browse/RF-6531 - description of tabindex attribute is added
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2009-03-18 17:04:23 UTC (rev 13008)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2009-03-18 17:14:38 UTC (rev 13009)
@@ -623,6 +623,7 @@
</property>
<property>
<name>tabindex</name>
+ <description>This attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros</description>
<classname>java.lang.String</classname>
</property>
</component>
15 years, 10 months
JBoss Rich Faces SVN: r13008 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-03-18 13:04:23 -0400 (Wed, 18 Mar 2009)
New Revision: 13008
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java
Log:
RF-6523
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java 2009-03-18 16:45:56 UTC (rev 13007)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java 2009-03-18 17:04:23 UTC (rev 13008)
@@ -350,8 +350,8 @@
AssertTextEquals(copyElemId, "kopieren");
AssertTextEquals(copyAllElemId, "kopieren alles");
- AssertTextEquals(removeElemId, "l�schen");
- AssertTextEquals(removeAllElemId, "l�schen alles");
+ AssertTextEquals(removeElemId, "l\u00f6schen");
+ AssertTextEquals(removeAllElemId, "l\u00f6schen alles");
}
@Test
15 years, 10 months
JBoss Rich Faces SVN: r13007 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/panelMenu and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-03-18 12:45:56 -0400 (Wed, 18 Mar 2009)
New Revision: 13007
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/menuPanelCosmeticTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
Log:
RF-6523
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-03-18 16:14:23 UTC (rev 13006)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-03-18 16:45:56 UTC (rev 13007)
@@ -53,12 +53,15 @@
private Map<String, String> inputs = new HashMap<String, String>();
+ private String selectedChild;
+
public RichPanelTestBean() {
value = "";
value2 = 0;
rendered = true;
content = "content";
immediate = false;
+ selectedChild = null;
}
public void reset() {
@@ -273,6 +276,7 @@
rendered = true;
content = "content";
immediate = false;
+ selectedChild = null;
}
/**
@@ -335,4 +339,12 @@
this.disabled = disabled;
}
+ public void setSelectedChild(String selectedChild) {
+ this.selectedChild = selectedChild;
+ }
+
+ public String getSelectedChild() {
+ return selectedChild;
+ }
+
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/menuPanelCosmeticTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2009-03-18 16:14:23 UTC (rev 13006)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2009-03-18 16:45:56 UTC (rev 13007)
@@ -334,7 +334,7 @@
writeStatus("Check selectedChild attribute is read on rendering and updated on form submit");
- String parentId = getParentId() + "row__form3:";
+ String parentId = "row_" + getParentId() + "_form3:";
assertClassNames(parentId + "pGroup2_selected", ITEM_HIGHLIGHTS, "Group 2 must be highlighted", true);
writeStatus("Click group 1");
15 years, 10 months
JBoss Rich Faces SVN: r13005 - trunk/test-applications/richfaces-docs/web/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-03-18 12:13:55 -0400 (Wed, 18 Mar 2009)
New Revision: 13005
Modified:
trunk/test-applications/richfaces-docs/web/src/main/webapp/colorPicker.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-6419
Added skinning and standard components skinning
Modified: trunk/test-applications/richfaces-docs/web/src/main/webapp/colorPicker.xhtml
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/webapp/colorPicker.xhtml 2009-03-18 16:13:22 UTC (rev 13004)
+++ trunk/test-applications/richfaces-docs/web/src/main/webapp/colorPicker.xhtml 2009-03-18 16:13:55 UTC (rev 13005)
@@ -20,13 +20,15 @@
<h:form>
- <rich:colorPicker value="#{colorPicker.value}" />
+ <rich:colorPicker value="#F0F8FF" />
</h:form>
<h:outputText value="#{colorPicker.value}" />
+
+
</rich:panel>
15 years, 10 months