Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable user to sort HTML table using JSP?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
1. I have a table in my JavaBean.
2. I print it to the user (the response).
3. The user should be able to sort it when clicking the column header.
How to make this possible?
I am stuck here.
I can't find any tutorial/sample doing something like this.
Does anyone know how to do this?
/stefan
 
> Does anyone know how to do this?

Yes

The user click must send all the information you need to perform the sort to your JSP page (the same one). There are different HTML/DHTML methods to accomplish that.

Your JavaBean sorts the table the sends back the response.

There, you are done.

Good luck
-pete
 
There are 2 ways of doing it.

1) The Server Side Sorting

U r using a bean to make a table rite? .. So all u need to make a bean which will make tables in sorted manner. for eg. U have a table having three columns User_name, User_email, Joining_date
So if i had to make a bean to generate a table. I would make three methods..
i) the default method where the whole table is sorted out by User_name
ii) The second method which will make a table by sorting User_email
iii) the third method will make a table sorting Joining_date
OR
U can have same method having three diffrent cases.. depending upon the values u pass to the bean,it makes the table.. This can get a bit complicated ,so i explained a simple but LENGTHY way first.
So now all u have to do is make links to the table headers in html which will call jsp file with a perticular parameter which can sent in query string for eg.. if the user clicks on User_email header in the table u call

2)Client Side sorting
Now the second way is dhtml thing in which u make all the three tables & hide 2 others in div or layers ( IE ,netscape comaptibility probs ) & when the user clicks
on which ever header u show the corresponding div or layer.
Well this dhtml thing is a bit too complex & depends on client browser so i wont prefer it.
So now its upto u, Which way to prefer. I hope this whole explanation will help u....
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top