Ferguson, Jason M TSgt 805 CSPTS/SCE wrote:
>Map paramMap = request.getParameterNames();
>for (Iterator it = paramMap.entrySet().iterator(); it.hasNext();)
>{
>    Map.Entry pairs = (Map.Entry) it.next();
>    String key = (String) pairs.getKey();
>    if (key.substring(0,2).equals("d-")) {
>        String[] pageArray = (String[]) pairs.getValue();
>        page = pageArray[0];
>        break;
>        }
>    }

I'd do this part a bit more like this:

Enumeration parameters = req.getParameterNames();
while(parameters.hasMoreElements())
{
    String parameter = (String) parameters.nextElement();
    if (parameter.startsWith("d-"))
    {
        page = request.getParameter(parameter);
        break;
    }
}

try
{
    startPage = Integer.parseInt(page);
}
catch (NumberFormatException ex)
{
    startPage = 1;
}

> Is there a better, cleaner way to get the table id and page number from
> the request?

Overall, not really, no.  You need to get the parameter and deal with it. 
The one thing I'd add is that "d-" parameters are displaytag parameters,
meaning that it's not exclusively the page.  It could also indicate sort
order and other display parameters.  I think there's a guide to the
various parameter formats around so that you can determine which is which,
but I don't remember where I saw that or if someone posted it to this list
or what.

-- 
Rick Herrick
[EMAIL PROTECTED]

Proud member of the reality-based community

Never try to discourage thinking for you are sure to succeed.--Bertrand
Russell

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to