You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> on 2006/08/04 15:36:00 UTC

Re: Selecting Row on sortable Datatable

Got the same issue.
Using preserveDataModel=false works.

Am Montag, den 10.07.2006, 10:11 -0700 schrieb Catalin Kormos:
> You're right, it's not working, but only if preserveDataModel=true; if
> you don't need your model to be preserved between requests, a
> temporary workarround, until this is resolved, might be to set it to
> false. Let me know if it works out for you with
> preserveDataModel=false and using the <t:updateActionListener>
> approach.
> 
> Regards,
> Catalin
> 
> joelus <jo...@beach.co.za> wrote:
>         
>         Thanks Catalin, but that still doesn't work... I don't know
>         what to do now,
>         should I give up on myfaces or what? It seems like such an
>         obvious thing but
>         even using your suggestion, the 'car' I get is the one
>         originally occupying
>         that row, not the one thats there after the sort. Any more
>         suggestions? Has
>         anybody actually done this and have it work?
>         -- 
>         View this message in context:
>         http://www.nabble.com/Selecting-Row-on-sortable-Datatable-tf1905482.html#a5248448
>         Sent from the MyFaces - Users forum at Nabble.com.
>         
> 
> 
> 
> 
> ______________________________________________________________________
> How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call
> rates.


Re: Fwd: Selecting Row on sortable Datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
On 8/8/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> How does saveState work - does it call the getter to get the data and
> then when restoring build the bean from scratch and calling the setter?

Yes, it calls the getter and puts the results into the component tree.

On restore,  it will restoreState the object.   If the object doesn't
implement StateHolder, it'll use Serialization.   [Un]Serialization
uses newInstance() to recreate the bean so no constructors will be
called, and the new object != to the old object in the Object.equals()
sense of the equality).   It then calls the setter with this value.

> Is the order relevant - e.g. calling the setWrappedData clears the
> sorted things - any call previous to this one to set the sort order back
> from the savedState will be lost in this case - what to do here?

Yes, I think the order is important.   You'll probably want to have
the saveState for the wrapped data before the saveState for the sort
behavior.

Re: Fwd: Selecting Row on sortable Datatable

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Hi again.

Trying to get the second working.

How does saveState work - does it call the getter to get the data and
then when restoring build the bean from scratch and calling the setter?
Is the order relevant - e.g. calling the setWrappedData clears the
sorted things - any call previous to this one to set the sort order back
from the savedState will be lost in this case - what to do here?

I made some changes to the SortableModel so i can expose the lists and
criteria which are responsible for sorting.
I save the lists and sort criteria but because i am not very deep in
saveState i cant get it work.
Any comments helping to clear how it works more in detail would be nice.

kind regards

Am Montag, den 07.08.2006, 11:48 -0400 schrieb Mike Kienenberger:
> Well, this sounds like a design issue in SortedDataModel.
> There's two things that need to be saved.
> One is the backing list -- that's being done.
> The second is the sort order of the data.   That seems like it needs
> to be exposed in SortedDataModel so you can also preserve that.   If
> it were me (and it's not yet as I haven't needed to add sorting to any
> of my tables), I'd look at the SortedDataModel and see what it'd take
> to give it a sort order accessor (It could simply return a List of
> Integers, where each integer represents the real index of the element
> in the backing list).  There may be some other sort state that needs
> preserved as well (which columns are being used for sorting and  the
> direction of each sort).   Actually,  this second set of data should
> be sufficient to recreate the sorted order of the data.
> 
> On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> > *light on*
> >
> > Yeah thats right.
> >
> > But still it doesnt work like preserveDataModel - the list is still
> > sorted like initial state if i go back to the page with a forward from a
> > detail one, so saving only the data is not enough, because like someone
> > already mentioned in the thread, the real list isn't sorted - this is
> > done somewhere in the model ( correct me if i am wrong ), because of
> > that i initially wanted to save the model - but thats not possible.
> >
> > So how can i preserve the state with saveState?
> >
> > Saving the SortCriteria + the Data did not help, neither saving the
> > sortColumn - ideas?


Re: Fwd: Selecting Row on sortable Datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
Well, this sounds like a design issue in SortedDataModel.
There's two things that need to be saved.
One is the backing list -- that's being done.
The second is the sort order of the data.   That seems like it needs
to be exposed in SortedDataModel so you can also preserve that.   If
it were me (and it's not yet as I haven't needed to add sorting to any
of my tables), I'd look at the SortedDataModel and see what it'd take
to give it a sort order accessor (It could simply return a List of
Integers, where each integer represents the real index of the element
in the backing list).  There may be some other sort state that needs
preserved as well (which columns are being used for sorting and  the
direction of each sort).   Actually,  this second set of data should
be sufficient to recreate the sorted order of the data.

On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> *light on*
>
> Yeah thats right.
>
> But still it doesnt work like preserveDataModel - the list is still
> sorted like initial state if i go back to the page with a forward from a
> detail one, so saving only the data is not enough, because like someone
> already mentioned in the thread, the real list isn't sorted - this is
> done somewhere in the model ( correct me if i am wrong ), because of
> that i initially wanted to save the model - but thats not possible.
>
> So how can i preserve the state with saveState?
>
> Saving the SortCriteria + the Data did not help, neither saving the
> sortColumn - ideas?

Re: Fwd: Selecting Row on sortable Datatable

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
*light on*

Yeah thats right.

But still it doesnt work like preserveDataModel - the list is still
sorted like initial state if i go back to the page with a forward from a
detail one, so saving only the data is not enough, because like someone
already mentioned in the thread, the real list isn't sorted - this is
done somewhere in the model ( correct me if i am wrong ), because of
that i initially wanted to save the model - but thats not possible.

So how can i preserve the state with saveState?

Saving the SortCriteria + the Data did not help, neither saving the
sortColumn - ideas?


Am Montag, den 07.08.2006, 10:56 -0400 schrieb Mike Kienenberger:
> On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> > Hm ok thats an idea and its working, however you have to be very careful
> > for chained models.
> >
> > SortableDataModel -> ListDataModel -> List<Typ>.
> >
> > Calling wrappedData on the first one is still not Serializable, you will
> > have to call it twice to get the real Data.
> > But thats implementation specific so its ok - thx for the tipp - tried
> > to save the whole bean which failed, but saving the data only works.
> >
> > A method like "getRealWrappedData" would be nice, to get the real "leaf"
> > of the DataModel Tree which maybe a chain, opinions?
> 
> Like I said, I find it easier to expose the List rather than the
> DataModel, and just serialize the list directly.   I've never resorted
> to the getWrappedData trick.


Fwd: Selecting Row on sortable Datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> Hm ok thats an idea and its working, however you have to be very careful
> for chained models.
>
> SortableDataModel -> ListDataModel -> List<Typ>.
>
> Calling wrappedData on the first one is still not Serializable, you will
> have to call it twice to get the real Data.
> But thats implementation specific so its ok - thx for the tipp - tried
> to save the whole bean which failed, but saving the data only works.
>
> A method like "getRealWrappedData" would be nice, to get the real "leaf"
> of the DataModel Tree which maybe a chain, opinions?

Like I said, I find it easier to expose the List rather than the
DataModel, and just serialize the list directly.   I've never resorted
to the getWrappedData trick.

Re: Selecting Row on sortable Datatable

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Hm ok thats an idea and its working, however you have to be very careful
for chained models.

SortableDataModel -> ListDataModel -> List<Typ>.

Calling wrappedData on the first one is still not Serializable, you will
have to call it twice to get the real Data.
But thats implementation specific so its ok - thx for the tipp - tried
to save the whole bean which failed, but saving the data only works.

A method like "getRealWrappedData" would be nice, to get the real "leaf"
of the DataModel Tree which maybe a chain, opinions?

kind regards 

Am Montag, den 07.08.2006, 10:05 -0400 schrieb Mike Kienenberger:
> On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> > Hm - thats not possible i guess. Using a SortableDataModel ( for
> > example ) which is not serializable by default, you have to make a
> > completly custom solution, extending and so on, to make it work.
> > So this parameter to preserve the model is nice, you get a stateful
> > model which can easily be sort by different SortCriterions.
> >
> > If you use sortable="true", your DataModel is automatically wrapped into
> > a SortableDataModel and you won't be able to use saveState component,
> > how did you solved this?
> >
> > kind regards
> >
> > Am Freitag, den 04.08.2006, 11:08 -0400 schrieb Mike Kienenberger:
> > > For what it's worth, I never use preserveDataModel=true.   Instead I
> > > perform a t:saveState on my backing list.
> > >
> 
> Again, you don't use saveState on your model.   You use it on the data
> inside the model.   However, I'm not sure if that's always possible.
> Again, I've never tried it, but DataModel.[gs]etWrappedData should
> return something you can serialize if you're not already making your
> underlying data available via accessors.


Re: Selecting Row on sortable Datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
On 8/7/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> Hm - thats not possible i guess. Using a SortableDataModel ( for
> example ) which is not serializable by default, you have to make a
> completly custom solution, extending and so on, to make it work.
> So this parameter to preserve the model is nice, you get a stateful
> model which can easily be sort by different SortCriterions.
>
> If you use sortable="true", your DataModel is automatically wrapped into
> a SortableDataModel and you won't be able to use saveState component,
> how did you solved this?
>
> kind regards
>
> Am Freitag, den 04.08.2006, 11:08 -0400 schrieb Mike Kienenberger:
> > For what it's worth, I never use preserveDataModel=true.   Instead I
> > perform a t:saveState on my backing list.
> >

Again, you don't use saveState on your model.   You use it on the data
inside the model.   However, I'm not sure if that's always possible.
Again, I've never tried it, but DataModel.[gs]etWrappedData should
return something you can serialize if you're not already making your
underlying data available via accessors.

Re: Selecting Row on sortable Datatable

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Hm - thats not possible i guess. Using a SortableDataModel ( for
example ) which is not serializable by default, you have to make a
completly custom solution, extending and so on, to make it work.
So this parameter to preserve the model is nice, you get a stateful
model which can easily be sort by different SortCriterions.

If you use sortable="true", your DataModel is automatically wrapped into
a SortableDataModel and you won't be able to use saveState component,
how did you solved this?

kind regards

Am Freitag, den 04.08.2006, 11:08 -0400 schrieb Mike Kienenberger:
> For what it's worth, I never use preserveDataModel=true.   Instead I
> perform a t:saveState on my backing list.
> 
> On 8/4/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> > Got the same issue.
> > Using preserveDataModel=false works.
> >
> > Am Montag, den 10.07.2006, 10:11 -0700 schrieb Catalin Kormos:
> > > You're right, it's not working, but only if preserveDataModel=true; if
> > > you don't need your model to be preserved between requests, a
> > > temporary workarround, until this is resolved, might be to set it to
> > > false. Let me know if it works out for you with
> > > preserveDataModel=false and using the <t:updateActionListener>
> > > approach.
> > >
> > > Regards,
> > > Catalin
> > >
> > > joelus <jo...@beach.co.za> wrote:
> > >
> > >         Thanks Catalin, but that still doesn't work... I don't know
> > >         what to do now,
> > >         should I give up on myfaces or what? It seems like such an
> > >         obvious thing but
> > >         even using your suggestion, the 'car' I get is the one
> > >         originally occupying
> > >         that row, not the one thats there after the sort. Any more
> > >         suggestions? Has
> > >         anybody actually done this and have it work?
> > >         --
> > >         View this message in context:
> > >         http://www.nabble.com/Selecting-Row-on-sortable-Datatable-tf1905482.html#a5248448
> > >         Sent from the MyFaces - Users forum at Nabble.com.
> > >
> > >
> > >
> > >
> > >
> > > ______________________________________________________________________
> > > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
> > > rates.
> >
> >


Re: Selecting Row on sortable Datatable

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Got some really mysterious thing.

Using UpdateActionListener with dataTable only - it only works with
preserveDataModel = false.
But using a dataScroller + the dataTable, i can use preserveDataModel =
true and it works - how could that be?

Can anyone confirm this odd behaviour?

kind regards

Am Freitag, den 04.08.2006, 11:08 -0400 schrieb Mike Kienenberger:
> For what it's worth, I never use preserveDataModel=true.   Instead I
> perform a t:saveState on my backing list.
> 
> On 8/4/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> > Got the same issue.
> > Using preserveDataModel=false works.
> >
> > Am Montag, den 10.07.2006, 10:11 -0700 schrieb Catalin Kormos:
> > > You're right, it's not working, but only if preserveDataModel=true; if
> > > you don't need your model to be preserved between requests, a
> > > temporary workarround, until this is resolved, might be to set it to
> > > false. Let me know if it works out for you with
> > > preserveDataModel=false and using the <t:updateActionListener>
> > > approach.
> > >
> > > Regards,
> > > Catalin
> > >
> > > joelus <jo...@beach.co.za> wrote:
> > >
> > >         Thanks Catalin, but that still doesn't work... I don't know
> > >         what to do now,
> > >         should I give up on myfaces or what? It seems like such an
> > >         obvious thing but
> > >         even using your suggestion, the 'car' I get is the one
> > >         originally occupying
> > >         that row, not the one thats there after the sort. Any more
> > >         suggestions? Has
> > >         anybody actually done this and have it work?
> > >         --
> > >         View this message in context:
> > >         http://www.nabble.com/Selecting-Row-on-sortable-Datatable-tf1905482.html#a5248448
> > >         Sent from the MyFaces - Users forum at Nabble.com.
> > >
> > >
> > >
> > >
> > >
> > > ______________________________________________________________________
> > > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
> > > rates.
> >
> >


Re: Selecting Row on sortable Datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
For what it's worth, I never use preserveDataModel=true.   Instead I
perform a t:saveState on my backing list.

On 8/4/06, Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> Got the same issue.
> Using preserveDataModel=false works.
>
> Am Montag, den 10.07.2006, 10:11 -0700 schrieb Catalin Kormos:
> > You're right, it's not working, but only if preserveDataModel=true; if
> > you don't need your model to be preserved between requests, a
> > temporary workarround, until this is resolved, might be to set it to
> > false. Let me know if it works out for you with
> > preserveDataModel=false and using the <t:updateActionListener>
> > approach.
> >
> > Regards,
> > Catalin
> >
> > joelus <jo...@beach.co.za> wrote:
> >
> >         Thanks Catalin, but that still doesn't work... I don't know
> >         what to do now,
> >         should I give up on myfaces or what? It seems like such an
> >         obvious thing but
> >         even using your suggestion, the 'car' I get is the one
> >         originally occupying
> >         that row, not the one thats there after the sort. Any more
> >         suggestions? Has
> >         anybody actually done this and have it work?
> >         --
> >         View this message in context:
> >         http://www.nabble.com/Selecting-Row-on-sortable-Datatable-tf1905482.html#a5248448
> >         Sent from the MyFaces - Users forum at Nabble.com.
> >
> >
> >
> >
> >
> > ______________________________________________________________________
> > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
> > rates.
>
>