2

I have created a table using display tag library (version 1.1) and I'm filling it with values from a data base. I do not want to show certain rows. For example i only want to show the records that match a given string or regular expression.

Records retrieved from database :

foo
bar
string1
foo2
bar2
string2

Given filter : "foo"

Expected Result :

foo
foo2

Remarks - I need to filter a list of cached records, i can't apply the filter directly to the database query.

Thanks for the help.

Igor
  • 33,276
  • 14
  • 79
  • 112
cosmincalistru
  • 1,283
  • 9
  • 20
  • And why would you want your presentation layer to manage your business logic? – maksimov Jun 11 '12 at 15:10
  • i know it's not the best approach, but i was given this task at work and refactoring the existing application would take too long. – cosmincalistru Jun 11 '12 at 15:14
  • if you're so constricted I guess you could always write a bit of JSP code `<% ... %>` to filter out the results you need into a new list, set this list as an attribute and use it as a data source for your `` instead of the list from the result set. – maksimov Jun 11 '12 at 15:20
  • The problem is that i am facing a very large data set and i was wondering if there is a way to do it whitout caching another list. The filters may be too general in some cases, and that would practically duplicate the data set. – cosmincalistru Jun 11 '12 at 15:37
  • Write your own tag? You are in a very bad design territory, don't expect to get off easily. – maksimov Jun 11 '12 at 15:40

1 Answers1

0
  1. If you want the Filters to work at client side only, without hitting the server, Try JQuery plugins. There are plenty of JQuery Plugins which does Sort and Filter/Search the Table or result sets.

  2. If you want the Server to Deal with that, write a Custom Implementation for org.displaytag.pagination.PaginatedList interface, and add your own Filter method, which you can invoke based on your search/sort criteria. Please Note that, if you implement this interface, then your List should be of PaginatedList type only. Refer the Interface Spec and DisplayTag and Display tag pagination problem for details.

Community
  • 1
  • 1