Reputation: 11
¿ How to paginate server side using DisplayTag (and Spring MVC)?
My controller code is like this:
@RequestMapping("/cuenta/refreshCombos.do")
public ModelAndView refreshCombos(HttpServletRequest request, HttpSession session,
@RequestParam(required= false, value="todas") Boolean todas,
@RequestParam("idBanco") Long idBanco) throws ParseException{
Map<String, Object> resul = new HashMap<String, Object>();
@SuppressWarnings("rawtypes")
Map paramMap = WebUtils.getParametersStartingWith(request, "d-");
if (paramMap.size() == 0) {
if (idBanco == 0){
cuentaList = obtenerCuentas(0L, true);
}
if (idBanco != 0){
cuentaList = obtenerCuentas(idBanco, false);
}
}
WebUtils.setSessionAttribute(request, "cuentaList", cuentaList);
resul.put("cuentas", cuentaList);
return forward("/cuenta/informeCuentas", resul);
}
And my DisplayTag in JSP, like this:
<display:table class="displayTags_wrapper" uid="cuenta" name="sessionScope.cuentaList" pagesize='50' defaultsort="1" defaultorder="ascending" requestURI="">
<display:column property="becado" sortable="true" title="Becado" maxLength="25" />
<display:column property="apellido" sortable="true" title="Titular Cuenta" maxLength="25" />
<display:column property="nroCuil" sortable="true" title="CUIL" maxLength="22" />
<display:column property="apellidoRR" sortable="true" headerClass="sortable" title="RR" maxLength="25" />
<display:setProperty name="basic.empty.showtable" value="true" />
<display:setProperty name="paging.banner.group_size" value="35" />
<display:setProperty name="paging.banner.item_name" value="cuenta" />
<display:setProperty name="paging.banner.item_names" value="cuentas" />
<display:setProperty name="paging.banner.onepage" value=" " />
</display:table>
This way, my pager works fine, but client side...
Any help or modifications to server-side paging?
Regards,
CaktusJP.
Upvotes: 1
Views: 4777
Reputation: 692211
See http://www.displaytag.org/1.2/tut_externalSortAndPage.html. The idea is to pass an instance of org.displaytag.pagination.PaginatedList
to the tag instead of a java.util.List
.
If this is the case, then the tag will generate hrefs with not encoded parameters for the page number to load, the sort criterion and direction (asc, desc) to use, and an optional search ID used, for example, to cache your query result at server-side.
In this case, it's of your responsibility to read these parameters, and perform the queries allowing the creation of a PaginatedList
instance.
Upvotes: 1