| Issue 257: | Search using 2 dates | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hello to everybody!! I have 2 "Date columns" (Column "FROM" and Column "TO"), and I would like to search all the information between that date. How could I do it?? Thanks so much for your attention ;)
Apr 7, 2010
Project Member
#1
jeff.johnston.mn@gmail.com
Status:
Accepted
Apr 9, 2010
I've follow your indications, and finally I created a FilterMacher class: tablefacade.addFilterMatcher(new MatcherKey(Date.class, "from"), new FilterNewsFrom()); tablefacade.addFilterMatcher(new MatcherKey(Date.class, "to"), new FilterNewsTo()); I've a problem with the field "TO". All my news without TO (field "To"=null)never don't expire and if I search with a date in that field, JMesa don't show me the news with To=null. Only search if "To" get a date to compare. ------------------- public class FilterNewsTo implements FilterMatcher { @Override public boolean evaluate(Object itemValue, String filterValue) { Log logger = CmsLog.getLog("es.sopde.panelmunicipios.templates.plantillaGestorNoticias.jsp"); Date dateTo = (Date)itemValue; try{ SimpleDateFormat sdf= new SimpleDateFormat("dd/MM/yyyy"); Date dateSearch = sdf.parse(filterValue); if (dateTo==null || dateTo.after(dateSearch)) return true; else return false; }catch (ParseException e){ logger.error("******* ParseException:" + e.getMessage()); System.out.println("**ERROR: No se ha podido transformar el filtro de búsqueda de la \"Fecha Hasta\" en un tipo Date. -- " + e.getMessage()); return false; }catch (Exception e){ logger.error("******* ParseException:" + e.getMessage()); System.out.println("**ERROR: Fallo al filtrar el campo \"Fecha Hasta\". -- " + e.getMessage()); return false; } } }
Apr 9, 2010
If you want to modify that behavior you could plug in your own row filter functionality. https://code.google.com/p/jmesa/wiki/CustomSimpleRowFilter Except what you will need to do is override the filterItems() method and plug in a custom filter predicate. Just take the existing predicate and tweak it out how you need to. You know what I should do as well is make it so that you can just extend the SimpleRowFilter and plug in your predicate. Even though there is not much to the filterItems() method it would still be much more flexible.
Mar 10, 2011
There is now a getPredicate() method on SimpleRowFilter. It is checked into the trunk and will go out with the 3.0.4 release.
Status:
Fixed
|