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
deepak1.3956330618074822E12deepak1.3956330618074822E12 

Saving Checkbox selection in VF page

Hello All,

I have the following code where i am trying to display a list of Checkbox items in a custom link from a Case page. The below code displays all the checkboxes and the labels but when i select the checkbox and save and then come back to the same link, the checkbox selections are gone. I dont want to use "inputcheckbox value" as my itemlabels are different and lengthy. can anyone help on this?

<apex:page standardController="Case" extensions="ChecklistController" tabStyle="Case" >
<apex:form >
<apex:pageBlock id="theBlock">
<apex:pageBlockSection >
            <apex:pageBlockSectionItem >Config Checklist:
                <apex:selectcheckboxes layout="pageDirection">
                     <apex:selectOption itemLabel="Confirm that General Exceptions are handled when configuring the site" itemvalue="onclick" rendered="true"/>
                     <apex:selectOption itemLabel="Confirm that SBW, burst factor and billing model matches the SEO form" itemvalue="onclick" />
                     <apex:selectOption itemLabel="Capture MTR and check for the nearest POP" itemvalue="onclick" />
                     <apex:selectOption itemLabel="Ensure that If POP has one ISP and a BGP IP, select the IP with the lowest latency" itemvalue="onclick" />
                     </apex:selectcheckboxes>     
              </apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Regards
Deepak
MithunPMithunP
Hi Deepak,

On save button action, you need to query the case details and add checkbox field values to the "itemvalue" attribute. So that it will display checkbox values from server, once you saves the record. If you still face any probs can you share your controller code.

Best Regards,
Mithun.
deepak1.3956330618074822E12deepak1.3956330618074822E12
Hi Mithun,

Thank you for looking into. The controller code is as below

public with sharing class ChecklistController{

    public Case cs { get; set; }
    public ApexPages.StandardController c;

    public ChecklistController(ApexPages.StandardController controller){
        this.cs = (Case)controller.getRecord();
        c = controller;

    }

    public PageReference saveRecord(){
        try{
            c.save();
        }
        catch(Exception e){
        }
        return null;
    }
}

Regards
Deepak