I have a requirement where I want divide the Visualforce page into 3 different pages having the dynamic count of the pages

I.e. I want put a next button on every page/section and when I click on it a new section/page has to appear and it has to carry the values from page to another since I would be having the submit button in the last section/page and I should even display the count of number section on each page dynamically ....

Can any one suggest with best approach on how to achieve this functionality

  • You must have 3 differents pages or having a single page with 3 blocks that you hide/show can be a solution ?
    – SF_user
    Feb 19, 2015 at 10:44

4 Answers 4


Two methods for accomplishing this. One would be to pass the page count as a parameter on the URL


Then on the new page, read the parameter in for your reference.

Second method is the "wizard" method, use the same controller for each page, and when you change pages, make sure the page redirect is false so the controller persists across page views.

  • Can i know do we any disadvantages in using a wizard...
    – user6833
    Feb 19, 2015 at 14:05
  • 1
    I think the wizard method is more powerful, especially if you had a lot of data that needed to pass from page to page. Also more secure, since the attributes are not exposed to the user on the URL.
    – JimRae
    Feb 19, 2015 at 14:38

You can use one single VF page with 3 different sections and keep rendering the section whenever next button is clicked. In this way you can you ca retain the values.


JimRae's answer is correct and this is how you read the parameter :

String par = ApexPages.currentPage().getParameters().get('pg');

One simple idea would be to create custom object representing state, and ask for it and update it when needed.

It would be also advisable to look at salesforce wizard example - it shows 3 views running on same controller and it seems to be retaining information through navigation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.