Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Monique Y. Mudama - 27 Jun 2005 22:44 GMT
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 TableSorter.java 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.

Signature

monique

Monique Y. Mudama - 28 Jun 2005 02:01 GMT
[snip]

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

Signature

monique



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.