Fix bug in SerializableListDataModel

This is a follow-up on an earlier commit:
97cc86b7c1

Issue: SWF-1510
This commit is contained in:
Rossen Stoyanchev
2014-05-29 20:53:31 -04:00
parent 59b0938e04
commit b7a718ddaf
2 changed files with 17 additions and 1 deletions

View File

@@ -24,9 +24,10 @@ import org.springframework.util.Assert;
/**
* A {@link DataModel} implementation that tracks the currently selected row, allowing only one selection at a time.
*
*
* @author Jeremy Grelle
*/
@SuppressWarnings("serial")
public class OneSelectionTrackingListDataModel<T> extends SerializableListDataModel<T> implements SelectionAware<T> {
/**

View File

@@ -15,6 +15,9 @@
*/
package org.springframework.faces.model;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -29,8 +32,10 @@ import org.springframework.util.Assert;
* @author Jeremy Grelle
* @author Phillip Webb
*/
@SuppressWarnings("serial")
public class SerializableListDataModel<T> extends ListDataModel<T> implements Serializable {
public SerializableListDataModel() {
this(new ArrayList<T>());
}
@@ -59,6 +64,16 @@ public class SerializableListDataModel<T> extends ListDataModel<T> implements Se
super.setWrappedData(data);
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.writeObject(getWrappedData());
oos.write(getRowIndex());
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
setWrappedData(ois.readObject());
setRowIndex(ois.read());
}
public String toString() {
return getWrappedData().toString();
}