Author: nbelaevski
Date: 2008-08-26 19:38:52 -0400 (Tue, 26 Aug 2008)
New Revision: 10204
Modified:
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
Log:
https://jira.jboss.org/jira/browse/RF-2049
Modified: trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
---
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-08-26
22:11:44 UTC (rev 10203)
+++
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-08-26
23:38:52 UTC (rev 10204)
@@ -76,6 +76,10 @@
this.map = null;
}
}
+
+ protected Map getMap() {
+ return this.map;
+ }
}
public static final class ValueHolder implements Serializable {
Modified:
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
===================================================================
---
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-08-26
22:11:44 UTC (rev 10203)
+++
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-08-26
23:38:52 UTC (rev 10204)
@@ -22,7 +22,10 @@
package org.richfaces.component;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.faces.application.FacesMessage;
import javax.faces.component.UICommand;
@@ -38,6 +41,8 @@
import javax.faces.validator.ValidatorException;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIListShuttle.SubmittedValue;
+import org.richfaces.model.ListShuttleRowKey;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
@@ -205,6 +210,63 @@
assertEquals(value, value2);
}
+ public void testSourceTargetDecode() throws Exception {
+ String shuttleId = listShuttle.getClientId(facesContext);
+
+ externalContext.addRequestParameterMap(shuttleId, "0:a");
+ externalContext.addRequestParameterMap(shuttleId, "t5:b");
+ externalContext.addRequestParameterMap(shuttleId, ":");
+ externalContext.addRequestParameterMap(shuttleId, "t1:c");
+ externalContext.addRequestParameterMap(shuttleId, "2:d");
+ externalContext.addRequestParameterMap(shuttleId, "t10:e");
+
+ listShuttle.decode(facesContext);
+
+ SubmittedValue value = (SubmittedValue) listShuttle.getSubmittedValue();
+ assertNotNull(value);
+
+ Map map = value.getMap();
+
+ Iterator<Map.Entry<ListShuttleRowKey, Object>> itr =
map.entrySet().iterator();
+ Entry<ListShuttleRowKey, Object> entry;
+ ListShuttleRowKey rowKey;
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("a", entry.getValue());
+ assertTrue(rowKey.isFacadeSource());
+ assertTrue(rowKey.isSource());
+ assertEquals(Integer.valueOf(0), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("b", entry.getValue());
+ assertTrue(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(5), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("c", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(1), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("d", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertTrue(rowKey.isSource());
+ assertEquals(Integer.valueOf(2), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("e", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(10), rowKey.getRowKey());
+ }
+
protected class ListShuttleBean {
private List value = null;
Modified:
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
===================================================================
---
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-08-26
22:11:44 UTC (rev 10203)
+++
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-08-26
23:38:52 UTC (rev 10204)
@@ -394,7 +394,7 @@
}
assertEquals(items.size(), rowsCount);
}
-
+
protected class SimpleItem {
String name;
int salary;