Menu

defaultOrder problem by PaginatedList

gandalf
2006-11-07
2012-10-09
  • gandalf

    gandalf - 2006-11-07

    Hi,
    I'm using implementation of PaginatedList with displayTag and I have some problems to set initial sorting order for column.
    By default param 'dir' in header's URL is set to 'asc' and setting 'defaultOrder' to 'descending' in column declaration das not change a thing, parameter 'defaultOrder' seems to be ignored for paginated lists.
    Is it a bug or maybe I'm doing something wrong?

    I've checked the source code and in HtmlTableWriter.getSortingHref() for paginatedList dirParam is always set to 'asc' (defaulOrder param is not taken under consideration):
    <code>
    if (headerCell.isAlreadySorted())
    {
    dirParam = tableModel.isSortOrderAscending() ? properties.getPaginationDescValue() : properties
    .getPaginationAscValue();
    }
    else
    {
    dirParam = properties.getPaginationAscValue();
    }
    </code>

     
    • Fuad Efendiyev

      Fuad Efendiyev - 2007-03-13

      Sorry, I was wrong... Message from gandalf (forysiak) seems correct...
      This works fine for me:
      else {
      //dirParam = properties.getPaginationAscValue();
      dirParam = tableModel.isSortOrderAscending() ? properties.getPaginationDescValue() : properties
      .getPaginationAscValue();

              }
      
       
    • Fuad Efendiyev

      Fuad Efendiyev - 2007-03-13

      I believe this is a bug in TableTag class, see last statement this.tableModel.setSortOrderAscending(direction == SortOrderEnum.ASCENDING);

          if (this.paginatedList == null)
          {
              SortOrderEnum paramOrder = SortOrderEnum.fromCode(requestHelper
                  .getIntParameter(encodeParameter(TableTagParameters.PARAMETER_ORDER)));
      
              // if no order parameter is set use default
              if (paramOrder == null)
              {
                  paramOrder = this.defaultSortOrder;
              }
      
              boolean order = SortOrderEnum.DESCENDING != paramOrder;
              this.tableModel.setSortOrderAscending(order);
          }
          else
          {
              SortOrderEnum direction = paginatedList.getSortDirection();
              this.tableModel.setSortOrderAscending(direction == SortOrderEnum.ASCENDING);
          }
      
       

Log in to post a comment.