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
MSVRadMSVRad 

<apex:inputCheckbox> is not getting set after a save

I have visualforce code and apex code for a controller extension where I have a boolean property that sets the input checkbox to false initally.

 

Here is the controller extension:

public with sharing class GoLiveController { public Go_Live_Process__c glp; public apexpages.standardController controller {get; set;} public GoLiveController(ApexPages.StandardController stdController) { // constructor controller = stdController; this.glp= (Go_Live_Process__c)stdController.getRecord(); Go_Live_Process__c goLives = (Go_Live_Process__c)stdController.getRecord(); goLives = [SELECT Account__c FROM Go_Live_Process__c WHERE id=:system.currentpageReference().getparameters().get('id')]; } //Property for Credentialing checkbox public Boolean showCredentialing{ get{ if(showCredentialing == null){ showCredentialing = false; } return showCredentialing; } set; } //Property for client agreement checkbox public Boolean showClientAgreement{ get{ if(showClientAgreement == null){ showClientAgreement = false; } return showClientAgreement; } set; } }

 

Here is the VF page:

<apex:page standardController="Go_Live_Process__c" extensions="GoLiveController"> <apex:form id="EditForm"> <apex:pageBlock title="Go Live Edit" id="TheBlock"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!delete}" value="Delete"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Go-Live General Information" columns="1" id="general"> <apex:outputField value="{!Go_Live_Process__c.Account__c}"/> <apex:pageBlockSectionitem id="CredBlock" > <apex:outputLabel value="Credentialing"/> <apex:inputCheckBox value="{!showCredentialing}"> <apex:actionSupport event="onclick" rerender="TheBlock" status="showCredentialing" /> </apex:inputCheckBox> </apex:pageBlockSectionitem> <apex:outputLabel value="{!showCredentialing}"/> <apex:pageBlockSectionitem > <apex:outputLabel value="Client Agreement"/> <apex:inputCheckBox value="{!showClientAgreement}"> <apex:actionSupport event="onclick" rerender="EditForm" status="showClientAgreement" /> </apex:inputCheckBox> </apex:pageBlockSectionitem> <apex:actionStatus startText="(rendering Credentialing Go Live...)" id="showCredentialing"/> <apex:actionStatus startText="(rendering Client Agreement Go Live...)" id="showClientAgreement"/> </apex:pageBlockSection> <apex:actionRegion > <apex:pageBlockSection title="Credentialing" rendered="{!showCredentialing}" id="CredentialingBlock" columns="2"> <apex:inputField value="{!Go_Live_Process__c.Privileges_issued__c}"/> </apex:pageBlockSection> </apex:actionRegion> </apex:pageBlock>

There is a similar post to this already and I have tried all of the suggestions on that post with no success. Here is the link to that post for reference: InputCheckbox will not set

 

I have an output field that shows that when I check it in the edit page that it is true, but after I save and go back in to edit it shows as false again.

 

Any suggestions would be greatly appreciated.

bob_buzzardbob_buzzard

What actually happens at this point - "but after I save and go back in to edit it shows as false again.".

 

If you are going to a different page and coming back, or carrying out a client side redirect, then I would expect the checkbox value to be reset to false, as you will have lost the view state and be coming back in anew.  You would then get a new instance of the controller, with the checkbox values null, which your getters set to false.

 

Are you saving the checkbox values into the Go_Live_Process_c?  

MSVRadMSVRad
I am not sure how I would save the checkbox value into the Go_Live_Process__c as its not really a field. This is what I think I am trying to do. All the checkboxes are being used for are for an action event so if the checkbox is checked then a section of the page is to display. If the checkbox is checked then we want it to remain checked unless a user unchecks it so that the pageBlockSection to be displayed when the checkbox is checked remain on the page.
bob_buzzardbob_buzzard

So the question still remains - what does saving and going back in to edit mean in terms of controller methods invoked and page references returned.

 

I'm guessing that you are losing the viewstate and reverting the checkboxes to their default unchecked state.

 

Can you show us the rest of the controller class?

MSVRadMSVRad

Thats all there is to the Controller right now.  I am trying to figure out what happens when the user saves the record then returns to the record by clicking edit. I haven't figured out a way to keep the checkbox checked. I am trying to write a wrapper class right now, but I am unsure how to keep the inputcheckbox checked so that the pageblocksection that renders onclick of the checkbox remains on the page.

 

how would I keep a viewstate entact? So that all changes made to the page remain displayed even after leaving the page and returning to it.