You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Emily Gu <e2...@gmail.com> on 2006/04/05 20:00:02 UTC
Re: why ListDataModel is not serializable
Hi,
I am getting following error by doing what you are suggested. Please help
me.
Cannot set value for expression '#{myCars.data.wrappedData}' to a new value
of type java.util.ArrayList.
The way I did is
<t:saveState value="#{myCars.data.wrappedData}"></t:saveState>
Thanks,
Emily
On 12/24/05, Dennis Byrne <de...@dbyrne.net> wrote:
>
> That's what I'm saying w/ <t:saveState value="#{b.dataModel.wrappedData}"
> /> . [gs]etWrappedData is the List ;)
>
> >-----Original Message-----
> >From: Mike Kienenberger [mailto:mkienenb@gmail.com]
> >Sent: Saturday, December 24, 2005 09:21 PM
> >To: 'MyFaces Discussion'
> >Subject: Re: why ListDataModel is not serializable
> >
> >Well, a ListDataModel always has an underlying data type you can save.
> >I always save the List instead of the DataModel using t:saveState.
> >
> >
> >On 12/24/05, Dennis Byrne <de...@dbyrne.net> wrote:
> >> ListDataModel is not Serializable because it is an implementation of
> DataModel, (not Serializable). This interface is defined by the spec, so
> there's no changing it.
> >>
> >> You can't use <t:saveState value="#{b.dataModel}" /> w/ client state
> saving, but you can use
> >> <t:saveState value="#{b.dataModel.wrappedData}" /> . However I
> remember having problems when doing this w/ the 1.0.9 release in
> combination with the DataModel.getRowData() . getRowData() was not
> returning the correct rowData (haven't tried this w/ any later build ).
> >>
> >> This problem is to be expected though. <t:saveState> takes a snap shot
> of the wrapped data during the render response phase of request x, and
> restores it during the restore view phase of request x + 1 . Doing this not
> only restored the data, but it appeared as though any notion of rowData was
> being wiped out. In a sense, it is like calling getRowData during the
> render response phase of request x - obviously there is no rowData if the
> dataTable has not even been rendered.
> >>
> >> You have options though. You can still use t:saveState but stop using
> getRowData(). Instead of getRowData(), use t:updateActionListener to "tell"
> the backing bean the id of the row that was chosen. Someone else around
> here may have something to say about another option : using
> @preserveDataModel for t:dataTable .
> >>
> >> >-----Original Message-----
> >> >From: Dave [mailto:javaone9@yahoo.com]
> >> >Sent: Saturday, December 24, 2005 05:09 PM
> >> >To: users@myfaces.apache.org
> >> >Subject: why ListDataModel is not serializable
> >> >
> >> >I need to use <saveState> to save a backing bean that has a data list
> of ListDataModel type.
> >> >
> >> > class BackingBean {
> >> > ListDataModel dataList;
> >> >
> >> > public DataModel getDataList() {
> >> > return dataList;
> >> > }
> >> > }
> >> >
> >> > the dataList is passed to <dataTable> for display/edit.
> >> >
> >> > But ListDataModel is not serializable. It might be ok for server
> side saving that actually keep everything in memory. But it will not work
> for client side saving.
> >> >
> >> > Why is ListDataModel not serializable?
> >> > The reason I use JSF ListDataModel instead of java.util.ArrayList is
> is that I need to know the current row from Backing Bean by
> >> > if (dataList.isRowAvailable()) {
> >> > Object currentRow = dataList.getRowData();
> >> > ....
> >> > }
> >> >
> >> > Is there another way to know the current row from backing
> bean? Event Listeners can access the UI component and its data model though
> the event. But the code is not in an event listener.
> >> >
> >> > Thanks and happy holiday!
> >> > Dave
> >> >
> >> >
> >> >
> >> >---------------------------------
> >> >Yahoo! for Good - Make a difference this year.
> >>
> >>
> >>
> >
>
>
>
Re: why ListDataModel is not serializable
Posted by Emily Gu <e2...@gmail.com>.
Hi Mike,
Thank you a lot. The way you gave works.
Thanks,
Emily
On 4/5/06, Mike Kienenberger <mk...@gmail.com> wrote:
>
> On 4/5/06, Emily Gu <e2...@gmail.com> wrote:
> > I am getting following error by doing what you are suggested. Please
> help
> > me.
> >
> > Cannot set value for expression '#{myCars.data.wrappedData}' to a new
> value
> > of type java.util.ArrayList.
> >
> > The way I did is
> >
> > <t:saveState value="#{myCars.data.wrappedData}"></ t:saveState>
>
> I've never tried the .wrappedData approach. Perhaps you cannot "set"
> data back into it in certain DataModels.
>
> My approach has always been to save the list instead.
>
> <t:saveState value="#{BackingBean.dataList}"/> in the original example.
>
Re: why ListDataModel is not serializable
Posted by Mike Kienenberger <mk...@gmail.com>.
On 4/5/06, Emily Gu <e2...@gmail.com> wrote:
> I am getting following error by doing what you are suggested. Please help
> me.
>
> Cannot set value for expression '#{myCars.data.wrappedData}' to a new value
> of type java.util.ArrayList.
>
> The way I did is
>
> <t:saveState value="#{myCars.data.wrappedData}"></ t:saveState>
I've never tried the .wrappedData approach. Perhaps you cannot "set"
data back into it in certain DataModels.
My approach has always been to save the list instead.
<t:saveState value="#{BackingBean.dataList}"/> in the original example.