You need to sign in to do that
Don't have an account?

Get the values from visualforce to apex.
Hi,
I am building a visualforce page for a survey which creates several questions using the <apex:repeat>.
The question info is pulled from DB and each question is having a radio button list.
Once the user selects his answers I want to get the result to apex class? Having hard time in getting the values of the radio button as they were created dynamically using the <apex:repeat>.
Any ideas how to to get the values?
Thanks
Raj
This sounds like a case for our old friend the wrapper class.
I'm assuming your questions are a custom object, but they don't contain a field that can back the radio button - essentially this is metadata about the question for use by the page.
1. Create a custom class inside your controller that holds the question object and a string to back the radio button.
2. When you retrieve the list of questions to be displayed, convert this to a list of the custom class.
3. Back your repeat tag with the list of custom class instances rather than questions
Then when the user makes their selections, your custom class instances will be updated via the viewstate and available to your code.
All Answers
This sounds like a case for our old friend the wrapper class.
I'm assuming your questions are a custom object, but they don't contain a field that can back the radio button - essentially this is metadata about the question for use by the page.
1. Create a custom class inside your controller that holds the question object and a string to back the radio button.
2. When you retrieve the list of questions to be displayed, convert this to a list of the custom class.
3. Back your repeat tag with the list of custom class instances rather than questions
Then when the user makes their selections, your custom class instances will be updated via the viewstate and available to your code.
Thanks Bob for your reply.
Yes, I successfully implement using what you have said above and also with the help of this post.
http://wiki.developerforce.com/index.php/Wrapper_Class
Thanks for your help.
Raj
I know this is an old thread, but do you have example code of the solution by any chance, I seem to be stuck in the exact same situation.