Search code examples
javajspsortingstrutsdisplaytag

JSP Display Tag Sorting Page Reload


Setup: I have a Struts web application where I use displaytag elements to do all of my table work. Each column is sortable.
Situation: When I click sort, on a long page, it sorts, but drops you at the top of the page.
Question: How do I use an anchor or some other method to come back to the table rather than the top of the page.

Addition: I have looked at ajax-tags:display to wrap the display:table tag, but would like to attempt to do this with just what I have already (html anchors maybe?) rather than including another dependency.


Solution

  • This was a whole lot easier than I first thought. All you need to do is set the requestURI of each display:table tag to # and the id of the table.

    For example

    <display:table name="tablename" id="tableid" sort="list" requestURI="" export="true">
    

    Changed to

    <display:table name="tablename" id="tableid" sort="list" requestURI="#tableid" export="true">