I"m trying to use displaytag with external paging and sorting. I've implemented the PaginatedList interface and trying to display an instance of that implemented class through the following code:
The table is displayed and paginations works fine, but sorting does not, as the link when a column head is clicked does not contain "sort=name", rather it shows a "sort=", an empty sort parameter, and without it it's not possible to the application to figure out what criterion should be used to sort the list.
Does anyone has a sugestion about what is going on?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You shoud add a "sortname" property to your column:
<display:column headerClass="align-left" titleKey="label.upload.list.file" sortable="true" sortname="ORDER_BY_FILE_NAME">
Then in you Controller or StrutsAction, do this:
ParamEncoder paramEncoder = new ParamEncoder("row");
String sortParameter = paramEncoder.encodeParameterName(TableTagParameters.PARAMETER_SORT);
String sort = request.getParameter(sortParameter);
if ("ORDER_BY_FILE_NAME".equals(sort)) {
......
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all, thanks for answering. For a while, I thought no one would answer. :-)
I tried the code you post, and "sort" is still evaluating to null when the column title is clicked. As it can be noted in the code I post, the "sortName" property is already set. The thing, I believe, is that when the mouse cursor is over the column name, the hyperlink shown at the bottom of the browser (i.e., the hyperlink that wil be called itself), the "sort" parameter is empty. It is empty although the "sortName" property is well-defined. In the example I post at the beginning of the thread, the hyperlink of the title of the column "Autoridade" is:
Hi, all!
I"m trying to use displaytag with external paging and sorting. I've implemented the PaginatedList interface and trying to display an instance of that implemented class through the following code:
<display:table requestURI="autoridades.do?sender=btPaginar" name="sessionScope.autoridades" class="padrao" sort="external" pagesize="10" id="a" cellpadding="0" cellspacing="0" >
The table is displayed and paginations works fine, but sorting does not, as the link when a column head is clicked does not contain "sort=name", rather it shows a "sort=", an empty sort parameter, and without it it's not possible to the application to figure out what criterion should be used to sort the list.
Does anyone has a sugestion about what is going on?
You shoud add a "sortname" property to your column:
<display:column headerClass="align-left" titleKey="label.upload.list.file" sortable="true" sortname="ORDER_BY_FILE_NAME">
Then in you Controller or StrutsAction, do this:
ParamEncoder paramEncoder = new ParamEncoder("row");
String sortParameter = paramEncoder.encodeParameterName(TableTagParameters.PARAMETER_SORT);
String sort = request.getParameter(sortParameter);
if ("ORDER_BY_FILE_NAME".equals(sort)) {
......
}
First of all, thanks for answering. For a while, I thought no one would answer. :-)
I tried the code you post, and "sort" is still evaluating to null when the column title is clicked. As it can be noted in the code I post, the "sortName" property is already set. The thing, I believe, is that when the mouse cursor is over the column name, the hyperlink shown at the bottom of the browser (i.e., the hyperlink that wil be called itself), the "sort" parameter is empty. It is empty although the "sortName" property is well-defined. In the example I post at the beginning of the thread, the hyperlink of the title of the column "Autoridade" is:
http://localhost:8080/MyApp/autoridades.do?sort=&sender=btPaginar&content=autoridades.jsp&searchid=&dir=asc
As it can be saw, "sort" is empty!
After many tries, I believe it is a bug! But I got no answer from the developers, as well.
Thanks!
Are you using the latest version of displaytag ?
try sortname instead of sortName ( who knows :D ).
I your case, replace, ParamEncoder paramEncoder = new ParamEncoder("row"); with
ParamEncoder paramEncoder = new ParamEncoder("a");
Yes, I'm using the last version (although I got some problems with caches when upgrading from 1.0 to 1.1).
I've also tried "sortname" instead of "sortName", but the tomcat complains about invalid syntax.