function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sravusravu 

Set the parameters in the page URL

Hi,

    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.................

raghu123raghu123

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

 

 

sravusravu

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

 

http://test.cs1.force.com/List?c=09aS00000008Rbi&category=&p=1

 

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.

 

 

http://test.cs1.force.com/List?c=09aS00000008Rbi&category=&p=5


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().clear();
              pageRef.getParameters().put('p',pNUM); //pNUM is the user inputted page number
              pageRef.setRedirect(true);

              return null;

              }


Thanks for the help.

ngabraningabrani

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.

sravusravu

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:

 

/apex/ideaLayout?c=09aS00000008Rbi&category=&j_id0%3Aj_id1%3Aj_id4%3Aj_id5%3Aj_id597=j_id0%3Aj_id1%3Aj_id4%3Aj_id5%3Aj_id597&j_id0%3Aj_id1%3Aj_id4%3Aj_id5%3Aj_id597%3Aj_id598=2&j_id0%3Aj_id1%3Aj_id4%3Aj_id5%3Aj_id597%3Aj_id599=j_id0%3Aj_id1%3Aj_id4%3Aj_id5%3Aj_id597%3Aj_id599&sort=recent