Buscar en rangos de fechas excluyendo la hora con paginaciòn
Copy < b : row >
< b : column medium - screen = "25" >
< a : searchBetweenDate
renderedMove = "true"
labelDesde = "#{msg['field.fechainicio']}"
valueDesde = "#{viajeController.lookupServices.fechaDesde}"
labelHasta = "#{msg['field.fechafin']}"
valueHasta = "#{viajeController.lookupServices.fechaHasta}"
renderedList = "#{applicationMenu.viaje.list}"
search = "#{viajeController.searchBy('_betweendates')}"
/>
</ b : column >
</ b : row >
Copy private Date fechaDesde;
private Date fechaHasta;
Copy viajeList = viajeRepository.filterBetweenDatePaginationWithoutHours("activo", "si", "fechahorainicioreserva", lookupServices.getFechaDesde(), "fechahorafinreserva", lookupServices.getFechaHasta(), page, rowPage, new Document("idviaje", -1));
Copy public String searchBy( String string) {
try {
loginController . put ( "searchviaje" , string);
writable = true ;
move() ;
} catch ( Exception e) {
errorServices . errorMessage ( nameOfClass() , nameOfMethod() , e . getLocalizedMessage ());
}
return "" ;
}
Copy public void move() {
try {
Document doc;
Document sort = new Document( "idviaje" , - 1 ) ;
switch ( loginController . get ( "searchviaje" )) {
case "_init" :
case "_autocomplete" :
viajeList = viajeRepository . findPagination (page , rowPage , sort);
break ;
case "idviaje" :
if ( lookupServices . getIdviaje () != null ) {
viajeList = viajeRepository.findPagination(new Document("idviaje", lookupServices.getIdviaje()), page, rowPage, new Document("idviaje", -1));
} else {
viajeList = viajeRepository . findPagination (page , rowPage , sort);
}
break ;
case "_betweendates" :
viajeList = viajeRepository.filterBetweenDatePaginationWithoutHours("activo", "si", "fechahorainicioreserva", lookupServices.getFechaDesde(), "fechahorafinreserva", lookupServices.getFechaHasta(), page, rowPage, new Document("idviaje", -1));
break ;
default:
viajeList = viajeRepository . findPagination (page , rowPage , sort);
break ;
}
viajeFiltered = viajeList;
viajeDataModel = new ViajeDataModel(viajeList) ;
} catch ( Exception e) {
errorServices . errorMessage ( nameOfClass() , nameOfMethod() , e . getLocalizedMessage ());
}
}
Componente searchBetweenDate
Copy <? xml version = '1.0' encoding = 'UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml"
xmlns : p = "http://primefaces.org/ui"
xmlns : composite = "http://java.sun.com/jsf/composite"
xmlns : b = "http://bootsfaces.net/ui"
xmlns : f = "http://xmlns.jcp.org/jsf/core"
xmlns : h = "http://xmlns.jcp.org/jsf/html" >
< composite : interface >
< composite : attribute name = "update" default = ":form:dataTable" />
< composite : attribute name = "labelDesde" />
< composite : attribute name = "valueDesde" />
< composite : attribute name = "labelHasta" />
< composite : attribute name = "valueHasta" />
< composite : attribute name = "colSpans" default= "2,3,2,3,2" />
< composite : attribute name = "renderedMove" default= "true" />
< composite : attribute name = "pattern" default = "dd/MM/yyy" />
< composite : attribute name = "columns" default= "3" />
< composite : attribute name = "renderedList" />
< composite : attribute name = "search"
method - signature = "java.lang.String action()" />
</ composite : interface >
< composite : implementation >
< p : remoteCommand name = "remotesearch"
update = "#{cc.attrs.update}" />
< b : panelGrid columns = "#{cc.attrs.columns}" size = "xs" colSpans = "#{cc.attrs.colSpans}" >
< p : outputLabel value = "#{cc.attrs.labelDesde}" />
< p : calendar
value = "#{cc.attrs.valueDesde}"
required = "false"
pattern = "#{cc.attrs.pattern}"
selectOtherMonths = "true"
navigator = "true"
/>
< p : outputLabel value = "#{cc.attrs.labelHasta}" />
< p : calendar
value = "#{cc.attrs.valueHasta}"
required = "false"
pattern = "#{cc.attrs.pattern}"
selectOtherMonths = "true"
navigator = "true"
/>
< b : commandButton update = "#{cc.attrs.update}"
look = "info"
oncomplete = "remotesearch()"
iconAwesome = "fa-filter"
rendered = "#{cc.attrs.renderedList}"
title = "#{app['button.search']}"
action = "#{cc.attrs.search}" />
</ b : panelGrid >
<!--</ b : panel >-->
</ composite : implementation >
</ html >