Requirements:
The implementation should satisfy the following requirements:
- support viewing all the logged events (in a DB) with provision for specifying the number of rows per page to show in a data grid of event records.
- support pagination.
- support sorting on columns like event time, id, type etc.
- support exporting events data to CSV, excel etc formats.
- change row color to highlight rows based on severity of events.
- enable viewing live events instantaneously as they occur.
Solution:
The first 5 requirements are easily met by Displaytag, an excellent JSP tag library for displaying data grids. We can also enable AJAX support for displaytag data grid pagination and sorting using ajaxtags library.
We did not like the live grid type views (which may be better suited to the search examples) for our requirement as we believe the pagination with Ajax support is more appealing and common experience for users.
The last requirement is met by DWR 2.0 (which as of this writing is still being developed and the current release is 2.0 RC2). DWR 2.0 has a new feature called Reverse AJAX, which enables pushing the data from server to browser client, asynchronously.
So, we have two data grids in our UI;
- First data grid, displays the existing event records from the DB.
- Second data grid, displays the live events using DWR's Reverse Ajax feature. One can use the recently added proxy for scriptaculous Javascript effects library, to highlight the new rows as they get added to the live events data grid. Adding new rows to the HTML table is facilitated by org.directwebremoting.proxy.dwr.Util class' addRows(String elementId, String[][] data) method. The implementation can choose to route the events to all browsers or selected browser sessions only - an event routing behavior. An example on reverse ajax feature is found here (see stock ticker).

