0

I'm making a self assessment portal on salesforce. The VF page needs to be divided into blocks because i want to refresh only the question. Being fairly new to the pagination concept, i need help for the next and previous command links. When someone starts the test, a map gets populated with 60 questions. everytime next is clicked i want the next map value to be rendered. I would be really obliged, if someone could help me with the same.

  • U want code to do that – Sunny Feb 6 '14 at 10:45
  • Code for the VF page? or the controller? – Sam Feb 6 '14 at 10:46
  • for both u want code – Sunny Feb 6 '14 at 11:13
  • yep. I need code for both – Sam Feb 6 '14 at 12:12
1

There are several ways to do this.

I would suggest starting with an array of questions as the order of a map is nondeterministic. Working with an array will guarantee that your forward/previous buttons always go to the correct next/previous question.

Begin with a class variable (declared at the top of your class) that is initialized in your constructor to 0, so something like currentQuestion=0;

On your next/previous buttons, you will want to bind an action function that increments/decrements the currentQuestion variable.

Then you should be able to display the question from the array using the currentQuestion variable as an index.

That should get you what you need, but it's much simpler than many pagination cases. Other use cases could require using limit and offset in a SOQL query.

I realize that I didn't give you the raw code that you asked for. However, I believe that doing so would be doing you a disservice. When working with straightforward tasks like this, you will learn much more thoroughly if you have to look the specifics up for yourself and you'll also have a better idea of how to look things up in the future.

| improve this answer | |
1

Not sure if you got this figured out but you could try Youreka for free from the AppExchange. It's all drag and drop. It will let you connect to any object/record, natively supports pagination, dependent questions and a series of different types of questions that link back to your Salesforce data.

https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000E6jHqEAJ

| improve this answer | |

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.