Author: nbelaevski
Date: 2008-12-24 13:41:33 -0500 (Wed, 24 Dec 2008)
New Revision: 12018
Added:
trunk/framework/api/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/model/SequenceRange.java
trunk/framework/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java
Log:
https://jira.jboss.org/jira/browse/RF-5454
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/model/SequenceRange.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/model/SequenceRange.java 2008-12-24
18:09:05 UTC (rev 12017)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/model/SequenceRange.java 2008-12-24
18:41:33 UTC (rev 12018)
@@ -46,6 +46,13 @@
}
/**
+ *
+ */
+ protected SequenceRange() {
+ super();
+ }
+
+ /**
* @param firstRow
* @param rows
*/
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java 2008-12-24
18:09:05 UTC (rev 12017)
+++
trunk/framework/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java 2008-12-24
18:41:33 UTC (rev 12018)
@@ -10,6 +10,7 @@
package org.richfaces.model;
+import java.io.IOException;
import java.io.Serializable;
import org.ajax4jsf.model.SequenceRange;
@@ -25,6 +26,10 @@
private SortOrder sortOrder;
+ public ScrollableTableDataRange() {
+ super();
+ }
+
public ScrollableTableDataRange(int first, int last, SortOrder sortOrder) {
super(first, last > 0 ? last - first : -1);
this.sortOrder = sortOrder;
@@ -94,4 +99,23 @@
return false;
return true;
}
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+
+ out.defaultWriteObject();
+
+ out.writeInt(getFirstRow());
+ out.writeInt(getRows());
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ in.defaultReadObject();
+
+ setFirstRow(in.readInt());
+ setRows(in.readInt());
+ }
+
}
Added:
trunk/framework/api/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java
===================================================================
---
trunk/framework/api/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java
(rev 0)
+++
trunk/framework/api/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java 2008-12-24
18:41:33 UTC (rev 12018)
@@ -0,0 +1,59 @@
+/**
+ * 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.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class ScrollableTableDataRangeSerializationTest extends TestCase {
+
+ private ScrollableTableDataRange readWriteRange(ScrollableTableDataRange range) throws
Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(range);
+ oos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+
+ return (ScrollableTableDataRange) ois.readObject();
+ }
+
+ public void testSerialization() throws Exception {
+ SortOrder order = new SortOrder(new SortField[] { new SortField("xxx", true)
});
+ ScrollableTableDataRange range = new ScrollableTableDataRange(10, 300, order);
+
+ ScrollableTableDataRange serializedRange = readWriteRange(range);
+
+ assertNotSame(range, serializedRange);
+ assertEquals(range, serializedRange);
+ }
+}