Thanks for the help... The parameter issue you mentioned was a dumb
mistake on my part, which I've fixed.
The fixed method is below so that anyone hunting the archives has it
available:
public Collection getPartialSoftwareList() {
int startPage;
String page="";
ServletRequest request = pageContext.getRequest();
Enumeration parameters = request.getParameterNames();
while (parameters.hasMoreElements()) {
String parameter = (String) parameters.nextElement();
// Check if it's a displaytag property and specifically the
page parameter
if (parameter.startsWith("d-") && parameter.indexOf("-p") >
0) {
page = request.getParameter(parameter);
break;
}
}
try {
startPage = Integer.parseInt(page);
} catch (NumberFormatException ex) {
startPage = 1;
}
return softwareService.getPartialSoftwareList(startPage, 30);
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, December 01, 2006 10:54 AM
To: [email protected]
Subject: Re: [displaytag-user] Table Information in the Request
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=DEVDE
V
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user