fixed bug #0007052 - Correção no PagedListWrapper para aceitar sorts com mais de um campo. Ex: sort="auto(campo1, campo2)". Adicionando o id como segunda ordenação é possível garantir que a paginação junto com a ordenação sempre irá ocorrer corretamente.
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@52239 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
445b21797f
commit
e9c749194d
|
@ -179,21 +179,25 @@ public class PagedListWrapper<E> implements Serializable {
|
|||
final Comparator<?> cmpr = lh.getSortDescending();
|
||||
if (cmpr instanceof FieldComparator) {
|
||||
String orderBy = ((FieldComparator) cmpr).getOrderBy();
|
||||
orderBy = StringUtils.substringBefore(orderBy, "DESC").trim();
|
||||
String[] multipleOrderBy = getMultipleOrderBy(orderBy, "DESC");
|
||||
|
||||
// update SearchObject with orderBy
|
||||
getSearchObject().clearSorts();
|
||||
getSearchObject().addSort(orderBy, true);
|
||||
for(String ob : multipleOrderBy){
|
||||
getSearchObject().addSort(ob,true);
|
||||
}
|
||||
}
|
||||
} else if ("descending".equals(sortDirection) || "natural".equals(sortDirection) || Strings.isBlank(sortDirection)) {
|
||||
final Comparator<?> cmpr = lh.getSortAscending();
|
||||
if (cmpr instanceof FieldComparator) {
|
||||
String orderBy = ((FieldComparator) cmpr).getOrderBy();
|
||||
orderBy = StringUtils.substringBefore(orderBy, "ASC").trim();
|
||||
String[] multipleOrderBy = getMultipleOrderBy(orderBy, "ASC");
|
||||
|
||||
// update SearchObject with orderBy
|
||||
getSearchObject().clearSorts();
|
||||
getSearchObject().addSort(orderBy, false);
|
||||
for(String ob : multipleOrderBy){
|
||||
getSearchObject().addSort(ob,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +213,16 @@ public class PagedListWrapper<E> implements Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String[] getMultipleOrderBy(String orderBy, String ascDesc){
|
||||
if(orderBy.contains(",")){
|
||||
return orderBy.replace(ascDesc, "").replace(" ", "").split(",");
|
||||
}else{
|
||||
return new String[]{StringUtils.substringBefore(orderBy, ascDesc).trim()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PagedListService getPagedListService() {
|
||||
return pagedListService;
|
||||
}
|
||||
|
|
|
@ -52,16 +52,16 @@
|
|||
label="${c:l('lb.id')}" sort="auto(fiscaltotnaofiscalId)"/>
|
||||
|
||||
<listheader image="/gui/img/create_doc.gif"
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.empresa.label')}" sort="auto(empresa.nombempresa)"/>
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.empresa.label')}" sort="auto(empresa.nombempresa,fiscaltotnaofiscalId)"/>
|
||||
|
||||
<listheader image="/gui/img/create_doc.gif"
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.tipototalizador.label')}" sort="auto(tipototalizador,fiscaltotnaofiscalId)"/>
|
||||
|
||||
<listheader image="/gui/img/create_doc.gif"
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.tipototalizador.label')}" sort="auto(tipototalizador)"/>
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.descricao.label')}" sort="auto(descricao,fiscaltotnaofiscalId)"/>
|
||||
|
||||
<listheader image="/gui/img/create_doc.gif"
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.descricao.label')}" sort="auto(descricao)"/>
|
||||
|
||||
<listheader image="/gui/img/create_doc.gif"
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.tipoeventoextra.label')}" sort="auto(tipoeventoextra.descTipoEvento)"/>
|
||||
label="${c:l('busquedaTotnaofiscalEmpresaController.tipoeventoextra.label')}" sort="auto(tipoeventoextra.descTipoEvento,fiscaltotnaofiscalId)"/>
|
||||
|
||||
</listhead>
|
||||
</listbox>
|
||||
|
|
Loading…
Reference in New Issue