You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dave Brondsema <da...@brondsema.net> on 2006/03/01 17:08:03 UTC

Re: MyFaces dataTable column sorting

devosc wrote:
> under what conditions might 'getAscending' be called ? From the
> definitions of Boolean.valueOf(String) it is only true when the
> sortAscending attr value is 'true', yet I cant see in any of the
> examples a 'getAscending' method ?
> 

You would use it in your code in your sorting method (or your DAO
querying method if you have the database do the sorting) to decide if
you should sort ascending or descending.

-- 
Dave Brondsema
Software Developer
Cornerstone University


Re: MyFaces dataTable column sorting

Posted by Greg <de...@gmail.com>.
Just to add...

It seems like that when implementing the large tables DataPage model,
to get the sort column to behave as expected the following is needed
(applying the DataPage model to the pagedSortTable example).

  public DataModel getDataModel() {
    //if (dataModel == null) {
      dataModel = new LocalDataModel(getRowsPerPage());
    //}

    return dataModel;
  }

Which is not really ideal.

Re: MyFaces dataTable column sorting

Posted by Greg <de...@gmail.com>.
getAscending is a method that is supposedly used in conjunction with
the sortAscending dataTable attribute (as a binding value). However
even if this method does exist in the managed bean this method is
never called. None of the myfaces examples implement a getAscending
method, even though in the jsp pages this value-binding has been
specified.

At present, in the Dao etc, the boolean method 'isAscending' can be
used since it exists in the sample abstract SortableList class.

The problem I'm having at the moment is that I've implemented the
working with large tables example (dataScroller), but trying to
combine this with the sort running me around in circles (i'm figuring
things out as I go along etc) ... etc, state_saving_method, managed
bean scope (request|session), preserveDataModel, preserveSort.... In
respect to those values, I've followed pagedSortTable.jsf so the only
difference being that I'm using the DataModel (large tables)
implementation, yet the sort does not work immediately.

Right now I'm totally confused, given one combination of the above
mentioned params, clicking a sort column will rebuild and display the
datamodel immediately, another permutation will send the request but
it wont be untill the next request that this change will be reflected
and persist (ascross paginations).... another permutation will not
reflect the changes untill the second page request but will then
subsequently lose the chosen sort value.

One problem I saw at point (when feeling closest to a solution), is
that when the page first loads _sortAscending = true, however clicking
the sort column, resends the 'true' in the request (or something) thus
no changes are reflected (since it originally was true)...

If someone who understands how things work (and maybe is/wether
immediate="true|false") is need and can put some perspective on this,
then I think it would be greatly appreciated and should be pinned
(documented etc).

G.