+ Start a Discussion

Set the parameters in the page URL


    I have a url with the parameter p (indicates page number)Something like p=2 indicates that the user is in 2 page of the list. What my requirement is when a user inputs the page number I want the user to land in that particular page. I tried all means but could not find a way. Could anyone help me on this.


Thanks in advance.................


 Hey Sorry, Hard to understand your problem....Provide some code if possible




Here is my URL. In the below URL there is a parameter 'p'. it is the current page number in the list page.




So my requirement is, When we have some 10 pages, instead of clicking next page link everytime to navigate back and forth, I want to allow users to input the page number to navigate to and let the user land in that particular page.

For example, if a user inputs 5 in the input box provided, I want the url to be updated as follows.




So that the user will land in page 5



I am using the following code


              public PageReference go(){

              PageReference pageRef = ApexPages.currentPage();
              pageRef = new PageReference(pageRef.getURL());
              pageRef.getParameters().put('p',pNUM); //pNUM is the user inputted page number

              return null;


Thanks for the help.


You need to return pageRef instead of returning null. That should do the job.

You may want to print pNum via a debug statement, to make sure the code is performing as intended.


Hi ngabrani,

                      I tried return pageRef, but it is redirecting to a different page and i am not getting the desired page. It is setting the parameter 'p' to the user inputted number. The URL is returned as follows with some junk values: