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
sancasanca 

Getting custom checkbox value ( not related to object) in apex

Hello All ,

I have designed a sample action function method to a call controller from JS and its working  fine.But  I need to do an enhancement like if checkbox is unselected the output text should not be rendered ( currenlty , once if the checkbox is selected , it remains forever) . Please help me ,below is the code.
P.S : Check box is not part of object , its just custom checkbox which is created in VF page
Visualforce 
------------------


Public class Actionfunction {
Public string MyString_From_Methode{get;set;}
    public Actionfunction(ApexPages.StandardController controller) {

    }

    public string ActionFunMethode(){
     MyString_From_Method = 'Method called from js using Action function';

  
     return null;
    }
}

Apex :
--------

<apex:page standardcontroller="Account" extensions="Actionfunction" tabStyle="Account">
    <apex:form >
       <apex:actionFunction name="actionFunName" action="{!ActionFunMethod}" reRender="outputtxtId"/>
       <apex:pageBlock > 
            <apex:outputLabel for="inptCheckBox" value="Check this box to call Controller method from js using ActionFunction" style="color:green;"></apex:outputLabel> 
            <apex:inputcheckbox onclick="javaScrpt()" id="inptCheckBox" />
       </apex:pageBlock> 
      
      <apex:outputText value="{!MyString_From_Methode}" id="outputtxtId" ></apex:outputText> 
    </apex:form> 
    
    <script>
      function javaScrpt(){
       actionFunName(); 
      }
    </script>
     
</apex:page>
Amit Chaudhary 8Amit Chaudhary 8
Please try wrapper classes for same.
https://developer.salesforce.com/page/Wrapper_Class

Please let us know if this will help you
 
sancasanca
ok Thanks , Let me try using wrapper class but is there any other way apart from wrapper class .