Friday, December 01, 2006

Using Displaytag with tiles

If you run the example in the previous post, with each click on the related table you will see that the URL has changed to reflect that of the JSP
http://localhost:8090/StrutsPaging/pages/search.jsp?d-3999332-p=2
This may cause problems when using Struts with tiles. In order to avoid the problem you have to change add a new attribute to the display:* tag
requestURI=""
In the JSP file in step 2 of "Struts: Paging and Sorting with Displaytag", change the display:table tag, change the tag to look as shown below:
<display:table name="sessionScope.empList" pagesize="4" id="empTable" sort="external" defaultsort="1" defaultorder="ascending" requestURI="">
Now, the URL appears as shown below
http://localhost:8090/StrutsPaging/search.do?d-3999332-o=2&d-3999332-s=empName&d-3999332-p=1&d-3999332-n=1
This solution in mentioned in the displaytag FAQ page(Had to dig a little to find it :) ). Once you have done this, you can safely use it with tiles too.

2 comments:

  1. Abhi,

    Is there a way in display tag to sort on multiple columns.

    Meaning when the list comes back I want it sorted like a
    order by col1, col3, col2 etc.,

    the defaultsort just does it for one

    Thanks,

    Nalina

    ReplyDelete
  2. Can I use Javascript in requestURI attribute in displaytag?

    ReplyDelete

Popular Posts