2

I want to jump to a specific page number using display tag with a textbox and a "go" button. On the click of GO button calls a javascript in which it should go to that specific page through that .htm which is not happening. please suggest an argument for this particular way of getting a specific page or else alternate suggestions are always welcome Below are the arguments in displaytag.properties which i know so far

enter code here

{0}: numbered pages list
{1}: link to the first page
{2}: link to the previous page
{3}: link to the next page
{4}: link to the last page
{5}: current page
{6}: total number of pages

Below is the javascript function which is being called on click of GO button

function selectPage(){
 alert("pageNo:" +document.portalDisplayform.selPageNo[0].value);
 alert("pageNo:" +document.portalDisplayform.selPageNo[1].value);
 var pageNo = document.portalDisplayform.selPageNo[0].value;
 var pageNo = document.portalDisplayform.selPageNo[1].value;
 document.portalDisplayform.action = '<%=request.getContextPath()%      >'+"/portalAccessdisplay.htm?tokenId="+'<%=cachetoken%>'+pageNo;
 document.portalDisplayform.submit();

}

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
Geetha
  • 21
  • 2
  • That has nothing to do with the spring framework, and nothing to do with java either. Please fix your question and the tags. – Angel O'Sphere Sep 16 '11 at 11:03
  • You're appending the page number to the cache token. Consider passing it as an actual URL parameter with a name. You don't state if you're doing server-side paging or not, are you? – Dave Newton Sep 16 '11 at 12:06

2 Answers2

0

The very easiest way, you can modify the TableTag.java which is in the display-tag jar file. In this file modify the initParameters() method. Inside the method place the below 4 line code. After this line which is in initParameters() method.

this.pageNumber = (pageNumberParameter == null) ? 1 : pageNumberParameter.intValue();

Place the below code

if((request.getParameter("pageno") != null) && (request.getParameter("pageno") != ""))
{
     this.pageNumber=Integer.parseInt(request.getParameter("pageno"))
}     

And use a TextBox with the name pageno in your DisplayTag page. Also include the name in your DisplayTag property excludedparam.

Gopi
  • 11
  • 3
0

It's not so easy, because the displaytag encodes parameters (to avoid naming conflicts with functional parameters), and uses a unique ID per table, in case several tables are on the same page. I suggest you download the source code of displaytag, have a look at the ParamEncoder and Pagination classes (and their callers) to discover how a link to a specific page is constructed by the displaytag. You'll have to use similar code to generate the URL, and you'll have to modify the value of the appropriate (encoded) parameter in your JavaScript code.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255