You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/03/26 22:40:01 UTC
Getting a value from the request object for variable for a custom tag?
Subject: Getting a value from the request object for variable for a custom tag?
From: "Preston Crawford" <pr...@REMOVESPAMBLOCKconceracorp.com>
===
I'm writing a custom pager for a resultset my company needs to page through.
I don't return every record, just the amount and set indicated by page size
and page number in the query. But I also want to return the total number
found.
So what I do, is in my action I make two calls..
request.setAttribute("ARRAYLIST_OF_STUFF", myCollection);
request.setAttribute("NUMBER_FOUND", intFound);
Now in the JSP page I forward to I retrieve ARRAYLIST_OF_STUFF to iterate
using the logic:iterate tag. However, here is the tricky part. I want to use
the number found as part of the pager tag. The reason being that the pager
tag needs to know how many records were found in order to produce the
following....
1-10 | 11-20 | 21-30..... etc...
So how do I get the value in my custom tag?
I've tried the following...
<pager:pager currentPage="2" pageSize="10" totalResults="<%=(Integer)
request.getAttribute("NUMBER_FOUND")%>" url="participantSearch.do">
..but that doesn't work. What works? Or am I approaching this entirely
wrong?
Preston
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Getting a value from the request object for variable for a custom tag?
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Struts" == Struts Newsgroup <(@Basebeans.com) <st...@basebeans.com>> writes:
Struts> Subject: Getting a value from the request object for variable for a custom tag?
Struts> From: "Preston Crawford" <pr...@REMOVESPAMBLOCKconceracorp.com>
Struts> ===
Struts> I'm writing a custom pager for a resultset my company needs to page through.
Struts> I don't return every record, just the amount and set indicated by page size
Struts> and page number in the query. But I also want to return the total number
Struts> found.
Struts> So what I do, is in my action I make two calls..
Struts> request.setAttribute("ARRAYLIST_OF_STUFF", myCollection);
Struts> request.setAttribute("NUMBER_FOUND", intFound);
Struts> Now in the JSP page I forward to I retrieve ARRAYLIST_OF_STUFF to iterate
Struts> using the logic:iterate tag. However, here is the tricky part. I want to use
Struts> the number found as part of the pager tag. The reason being that the pager
Struts> tag needs to know how many records were found in order to produce the
Struts> following....
Struts> 1-10 | 11-20 | 21-30..... etc...
Struts> So how do I get the value in my custom tag?
Struts> I've tried the following...
Struts> <pager:pager currentPage="2" pageSize="10" totalResults="<%=(Integer)
Struts> request.getAttribute("NUMBER_FOUND")%>" url="participantSearch.do">
Struts> ..but that doesn't work. What works? Or am I approaching this entirely
Struts> wrong?
Whenever you say "that doesn't work", it would help if you say what happens.
One minor change that might help is making sure your quotes nest properly.
This would mean changing the quoting around the "totalResults" attribute to be
a pair of single quotes, instead of double quotes.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>