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
Varun AnnadataVarun Annadata 

How to pass the value from getter method into another method?

I am getting Id value from visual force page into apex class.How do pass the id value from getter into another method for doing a soql query?
Varun AnnadataVarun Annadata
I am using visual components for assigning the id
Varun AnnadataVarun Annadata
Apex class:
public class CheckAlternateFunding {
   
  public string pmId;
      public void setpmId(String progMemId){
      pmId=progMemId;
    System.debug('pmId:'+progMemId);
   }
       public String getpmId(){
       return pmId;
  
   }
   
    public CheckAlternateFunding() {
        ViewData();
          }
   public List<Account> accounts {get;set;}
   public List<Account> accountsBlankType {get;set;}
   public List<Account> AllAc {get;set;}
  
  //
  public void ViewData(){     
       
      // String pmId = System.currentPageReference().getParameters().get('p');
      // System.debug('pmId...: ' + pmId);
        System.debug('pmId:'+pmId);
        String separator = ', ';
         
          
       if(pmId!=null){
       
        Program_Member_MVN__c pm = [select Id,Legal_US_Resident_IBND__c, Annual_Household_Income_IBND__c,Family_Size_IBND__c,Insurance_Type_C1__c, Primary_ICDCode_C1__c, Secondary_ICDCode_C1__c
                                                                from Program_Member_MVN__c
                                                                where  id =: pmId and Legal_US_Resident_IBND__c = 'Yes'];
                                                             
        //System.debug('Program Member...:' + pm);
        RecordType RT = new RecordType();
        List<RecordType> RTId= [select Id from RecordType where DeveloperName =: 'Charitable_Organizations'];
        System.debug('RTId...: ' + RTId);
        accounts = [select Id,Name, Disease_State_C1__c, Assistance_Type_C1__c, FPL_C1__c, Funding_Available_C1__c, Website, Status_IBND__c, Last_Funding_Check_Date_C1__c,Insurance_Type_C1__c,
                                                                Income_Threshold_C1__c, Residency_Requirement_C1__c from Account
                                                                where RecordTypeId =: RTId
                                                                and Insurance_Type_C1__c  /*=: pm.Insurance_Type_C1__c */ IN ('Private','Medicare','Medicaid','No Insurance') 
                                                                and Status_IBND__c =: 'Active'
                                                                and Funding_Available_C1__c = true];
      if(pm.Insurance_Type_C1__c == 'Private'){
        accountsBlankType = [select Id,Name, Disease_State_C1__c, Assistance_Type_C1__c, FPL_C1__c, Funding_Available_C1__c, Website, Status_IBND__c, Last_Funding_Check_Date_C1__c,Insurance_Type_C1__c,
                                                                Income_Threshold_C1__c, Residency_Requirement_C1__c from Account
                                                                where RecordTypeId =: RTId
                                                                and (Insurance_Type_C1__c =: '' or Insurance_Type_C1__c =: null)
                                                                and Status_IBND__c =: 'Active'
                                                                and Funding_Available_C1__c = true];
      }
     
     // if(accounts!= null)
        // AllAc.addall(accounts); 
     // if(accountsBlankType!= null)
     //  AllAc.addall(accountsBlankType);
       
        System.debug('accounts...: ' + accounts);
        System.debug('accountsBlankType...: ' + accountsBlankType);
      //  System.debug('AllAc...: ' + AllAc);
       
                          /* for(Account ac: accounts) {
                             FundingValues.add(String.valueOf(ac));
                             FundingValues.add('\n   ');
                           }
                           AcountListString.add(String.join(FundingValues, ', '));   */  
                           //String.join(listVariable, separator);
       
    
     //return accounts; 
     }
     else
     {
     }
      
 }  
}
visual force page:
<apex:page standardController="Program_Member_MVN__c" showHeader="false" standardStylesheets="false">
    <meta charset="utf-8"></meta>
    <meta name="viewport" content="width=device-width, initial-scale=1"></meta>
    <title></title>
    <c:AlternateFundingAccountView progMemId="{!Id}"/>
</apex:page>
visual Component:
<apex:component controller="CheckAlternateFunding">    
   <apex:attribute name="progMemId" type="String" description="The pm Id for the programmember we are working with" assignTo="{!pmId}" />
   <head>
        <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> 
        <apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
        <!--<apex:stylesheet value="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css" />-->     
        

      
        <script>
            j$ = jQuery.noConflict();
            j$(document).ready( function () {
                var accounttable = j$('[id$="accounttable"]').DataTable({
                    
                });
            });
        </script>
    </head>
    <body>
        <table id="accounttable" class="table table-striped table-bordered" Style="font-size: 11px;" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Assistance Type</th>
                    <th>Funding Available</th>
                    <th>FPL%</th>
                    <th>Eligible Insurance</th>
                    <th>Residency Requirement</th>                    
                    <th>Last Funding Check Date</th>
                    <th>Disease State</th>                   
                    <th>Website</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!accounts}" var="ac"> 
                    <tr>
                        <td>{!ac.Name}</td>
                        <td>{!ac.Assistance_Type_C1__c}</td>
                        <apex:outputPanel rendered="{!ac.Funding_Available_C1__c == true}">
                            <td>Yes</td>
                        </apex:outputPanel>
                        <apex:outputPanel rendered="{!ac.Funding_Available_C1__c != true}">
                            <td>No</td>
                        </apex:outputPanel>
                        <td>{!ac.FPL_C1__c}</td>
                        <td>{!ac.Insurance_Type_C1__c}</td>
                        <apex:outputPanel rendered="{!ac.Residency_Requirement_C1__c == true}">
                            <td>Yes</td>
                        </apex:outputPanel>
                        <apex:outputPanel rendered="{!ac.Residency_Requirement_C1__c != true}">
                            <td>No</td>
                        </apex:outputPanel>                       
                        <td>{!ac.Last_Funding_Check_Date_C1__c}</td>
                        <td>{!ac.Disease_State_C1__c}</td>
                        <td>{!ac.Website}</td>
                        <td>{!ac.Status_IBND__c}</td>
                        
                    </tr>
                </apex:repeat>
            </tbody>
        </table>
    </body>
</apex:component>