Velocity Reviews

Velocity Reviews (
-   Java (
-   -   Displaying results as "pages" of a JTable and sorting across all results ... (

Monique Y. Mudama 06-27-2005 09:44 PM

Displaying results as "pages" of a JTable and sorting across all results ...
Hi all ...

I've recently returned to the world of Java after an extended
sabbatical, but I'll admit that my grasp of TableModels and such was
never all that great.

So now I have a JTable question ... and it seems like such a common
need that there must be an obvious, known solution ...

I need to display a lot of results, one "page" at a time. I imagine a
JTable which is repopulated when the user clicks on a "Next" button.
On the face of it, that part seems pretty easy. I already have a
JTable that's repopulated based on new search terms.

Now, the result set in this case may be huge -- I simply can't request
the entire set of data at once. I can, however, query for results x
through y of the full set, and I can request the total number of hits.
Populating the TableModel and calling fireTableDataChanged(), again,
not a problem.

Here's the problem. I need the table to be sortable such that if the
user requests a change in the sort order of a column, the sort will take
effect across the entire set of data. If there were 100 hits and the
user is looking at the first 15, then clicks on the column heading, the
JTable would display the last 15 in reverse order. But again, I can't
have the full 100 (or 1,000 or 10,000) available locally; I would need
to query. I can query for the "first 15, descending order", that's not
a problem. But how do I go about modifying to do this?
When the user clicks on the header to sort by the column, instead of
actually sorting, I want to send a query and repopulate the table based
on the query.

Any pointers, hints, etc. gratefully accepted. I'm sure this is a
dumb question, but I can't seem to figure it out.


Monique Y. Mudama 06-28-2005 01:01 AM

Re: Displaying results as "pages" of a JTable and sorting across all results ...
On 2005-06-27, Monique Y. Mudama penned:


Looks like I was making things too complicated. A listener on the
JTableHeader ... that's what I needed.


All times are GMT. The time now is 02:04 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.