I usually have a list field which contains the serializable row
objects. This field is not transient. If you need the datamodel for
the datatable use a transient field for this and check in the getter
method for this field if the transient field and initialize it if it
is null. Doing so saves you a lot of time since writing the
serialization is not required any more.

2005/11/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> I have a Shale/MyFaces web app which upon logon displays a worklist.jsp
> which has a <t:datatable of "assignment" links. I am using tomahawk's
> datatable with sorting and paging with preserveDataModel as *false*. Also, I
> have STATE_SAVING_METHOD as client, and my WorkListManagerBean has scope of
> request.
>
> My WorkListManagerBean has a ListDataModel called assignmentsModel and a
> List _assignments. _assignments is a List of "ShaleAssignment" objects (I
> know, bad name!) which implements Serializable (using default
> serialization).
>
> In order to make everything work, I have had to make WorkListManagerBean
> implement Serializable. Seems to me I should declare _assignments and
> assignmentModel transient and then write methods
> writeObject(ObjectOutputStream) and readObject(ObjectInputStream). So, well,
> I did do all this, and everything seems to work fine. My question is just
> this: is this the correct approach or am i working too hard?
>
> Here are the details of my writeObject and readObject methods:
> private void writeObject(ObjectOutputStream s) throws IOException{
>
>         ..... //do default stuff first.. then:
>
>         List shaleAs = (List) assignmentsModel.getWrappedData();
>         Object[] shaleAsAsArray = shaleAs.toArray();
>         for (int i=0; i<shaleAsAsArray.length; i++) {
>                 s.writeObject(shaleAsAsArray[i]);
>         }
>
> }
> private void readObject(ObjectInputStream s) throws IOException,
> ClassNotFoundException {
>
>         ... //do default stuff.. then:
>
>         for (int i=0; i<size; i++) {
>                 shaleAssignmentsAsArray[i] = (ShaleAssignment)
> s.readObject();
>         }
>         _assignments = Arrays.asList(shaleAssignmentsAsArray);
>
>         // have to sort now I think..?
>         sort(_sort, _ascending);
>         assignmentsModel = new ListDataModel();
>         assignmentsModel.setWrappedData(_assignments);
>
> }
>
> Many thanks in advance for your help!
> Regards,
> Geeta


--
Mathias

Reply via email to