views:

493

answers:

2

Hi,

I'm currently developing a portlet for Liferay (using the Spring MVC framework). Now I just used the displaytag library for implementing paging on a list I'm displaying on the portlet.

My problem now is that I would need to detect whether the current request has been started by the paging control of the displaytag library. What I found is that when doing paging, a parameter is added in the URL that looks like "d-4157739-p=2" which indicates the current page that is shown. So I could do

int isPagingRequest = PortletRequestUtils.getIntParameter(request, "d-1332617-p", -1);

..and if the isPagingRequest (which I could change to a boolean) has a value then the request has been initiated by the displaytag paging. This is however very bad coding so I'd like to avoid it. Moreover the number between the "d" and "p" varies which makes it really hard to detect it.

Does someone have a suggestion how I can detect whether the current request has been provocated by a paging??

Thanks a lot

A: 

One option could be to add your own parameter to the value in the requestURI attribute. So for example, you could add this:

requestURI="mylistsource.action?ispage=true"

to the table tag, where mylistsource.action is your server action that generates the list in the first place.

On the server you can then look for the "ispage" parameter.

Vincent Ramdhanie
The problem with your solution is that the parameters are also placed on sorting links, so you'd get the ispage=true if the user selected to sort the table.
MetroidFan2002
+1  A: 

Displaytag provides a class "ParamEncoder" that (I think its in its constructor) produces the checksums for you based off the table name of your table (the id or uid element - this must be set to produce valid checksums (the numbers between d and -(parameter)). Check it out. TableTagParameters includes the constants needed for the parameters as well - so with a combination of these two, you can retrieve the appropriate variable key to retrieve from the request.

MetroidFan2002
Thanks a lot!! That was exactly what I was searching.
Juri