You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sundar Narasimhan <su...@ascent.com> on 2003/05/23 06:56:48 UTC

how to modify pager.offset within an action..

I have had this sort of problem before but can't quite recall what I
did to resolve it :)

Basically the problem has to do with the fact that inside struts
actions one cannot modify some request.parameter .. I'd sorely like to
be able to do
   request.setParameter("pager.offset", new String("0"));
before forwarding to a jsp..

Unfortunately only request.setAttribute() exists, and that doesn't
seem to be able to override a parameter that has already been set.

How do people typically do this? (What happens now is that I do a
query, get say 300 items.. and I scroll forward say to the 8'th page
and then resubmit the query, and the pager tag is still stuck at the
8'th page even though the new result set has far fewer items. I'd like
the pager offset to go back to 0 upon a new query. I am passing
pager.offset as a hidden parameter because there are other operations
where I do want the page to remain where it is).


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: how to modify pager.offset within an action..

Posted by Sundar Narasimhan <su...@ascent.com>.
   In a JSP, you can pass back a pager bean and then use a runtime 
   expression to pass the value to the pager tag.

   -Ted.
Hi, Ted: Thanks for responding. I don't quite understand what you are
suggesting though. Are you saying that I need to some how in my
action:
	pager = new PagerTag()..
	pager.setOffset(0);
	request.setAttribute("pager", pager);
and then forward to a jsp?	
	
Or are you saying do
       pageNo = parseInt(request.getParameter("pager.offset"));
       if (someSpecialAction) {
	   myBean.setPagerOffset(0);
       } else {
           myBean.setPagerOffset(pageNo);
       }
and then in my jsp somehow get the pager tag to use the pagerOffset
property in myBean? (I don't see where the pager is referencing
pager.offset just yet?) 

My use of the pager tag looks something like this.. right now:
<pg:pager items="<%= results.size() %>"		 
      index="center"
      maxPageItems="10"
      maxIndexPages="10"
      export="offset,currentPageNumber=pageNumber"
      url="/someUrl.do"
      scope="request">
  <input type="hidden" name="pager.offset" value="<%= offset %>">
 ...

   Sundar Narasimhan wrote:
   > I have had this sort of problem before but can't quite recall what I
   > did to resolve it :)
   > 
   > Basically the problem has to do with the fact that inside struts
   > actions one cannot modify some request.parameter .. I'd sorely like to
   > be able to do
   >    request.setParameter("pager.offset", new String("0"));
   > before forwarding to a jsp..
   > 
   > Unfortunately only request.setAttribute() exists, and that doesn't
   > seem to be able to override a parameter that has already been set.
   > 
   > How do people typically do this? (What happens now is that I do a
   > query, get say 300 items.. and I scroll forward say to the 8'th page
   > and then resubmit the query, and the pager tag is still stuck at the
   > 8'th page even though the new result set has far fewer items. I'd like
   > the pager offset to go back to 0 upon a new query. I am passing
   > pager.offset as a hidden parameter because there are other operations
   > where I do want the page to remain where it is).


   -- 
   Ted Husted,
   Struts in Action <http://husted.com/struts/book.html>



   ---------------------------------------------------------------------
   To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
   For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: how to modify pager.offset within an action..

Posted by Ted Husted <hu...@apache.org>.
In a JSP, you can pass back a pager bean and then use a runtime 
expression to pass the value to the pager tag.

-Ted.

Sundar Narasimhan wrote:
> I have had this sort of problem before but can't quite recall what I
> did to resolve it :)
> 
> Basically the problem has to do with the fact that inside struts
> actions one cannot modify some request.parameter .. I'd sorely like to
> be able to do
>    request.setParameter("pager.offset", new String("0"));
> before forwarding to a jsp..
> 
> Unfortunately only request.setAttribute() exists, and that doesn't
> seem to be able to override a parameter that has already been set.
> 
> How do people typically do this? (What happens now is that I do a
> query, get say 300 items.. and I scroll forward say to the 8'th page
> and then resubmit the query, and the pager tag is still stuck at the
> 8'th page even though the new result set has far fewer items. I'd like
> the pager offset to go back to 0 upon a new query. I am passing
> pager.offset as a hidden parameter because there are other operations
> where I do want the page to remain where it is).


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org