You need to sign in to do that
Don't have an account?
NewIntern
Simple VF question: Saving checkbox selection after VF page reload / refresh
I have a visualforce page with standard controller 'contact' and an extension class. This visualforce page appears in a section on each Contacts record page. The page renders several SObject checkboxes.
The issue is when a user clicks the checkbox, the selection is not remembered when the Contacts record page and therefore the VF page section are reloaded. How do I code the VF page so that when the Contact record is opened again, the checkboxes that were checked remain checked?
Please help.
Well, I just used the following code in my Apex class:
This works like a charm.
All Answers
The issue is when a user clicks the checkbox, the selection is not remembered when the Contacts record page and therefore the VF page section are reloaded.
Sorry for the lack of clarity.
I meant the selection is not remembered when the Contacts record page is reloaded. The checkbox is on a VF page and this VF page I have put in a section on the Contacts records. When I revisit the Contacts record, the VF page gets refreshed and the earlier user input of checking the checkbox is lost.
Essentially, I want to 1) navigate to Contact tab and view the record, 2) select the checkbox in the VF page that you see, 3) go elsewhere and come back to Contacts to see the same checkbox selected. Currently, the checkbox selection gets refreshed or removed when I refresh the Contacts record.
Here's my code:
<apex:page standardController="Contact" extensions="VFforEmailTemplateController">
<apex:form >
<apex:pageBlock id="theBlock">
</apex:column>
<apex:column headerValue="On Approved List" width="111">
<apex:inputField value="{!c.EJF_On_Approved__c}">
<apex:actionSupport event="onclick" reRender="theBlock" action="{!check_selection}"/>
</apex:inputfield>
</apex:column>
I did not write any code in the controller extension. Here EJF_On_Approved is the name of the SObject which is a custom checkbox.
http://developer.force.com/cookbook/recipe/selectable-sobjects-for-use-with-datatables-and-checkboxes
http://boards.developerforce.com/t5/Visualforce-Development/Retrieve-selected-checkbox-value/td-p/420451
Thanks for those links. However, there are way too complicated for me.
My requirement is simple. I don't even want to perform any action when a checkbox is selected.
All I want for is when the user checks this SObject custom checkbox 'EJF_On_Account' displayed in my VF page (which is on the page layout of Contacts), this selection is remembered. So the next time I view the contact record or navigate back to the contact record, I see the checkbox checked just like the user last saw, not unchecked as I see it now each time the VF page is refreshed.
I know the solution is not complicated. I'm actually surprised that there is no inherent/auto saving of a change made to a custom object field.
Need help.
http://boards.developerforce.com/t5/Visualforce-Development/Visualforce-page-loses-field-value-when-refreshing/td-p/166465
Well, I just used the following code in my Apex class:
This works like a charm.