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
Shravya Rama 9Shravya Rama 9 

A method is getting called unnecessarily

For some reason, getmycust() method is getting called as soon as the page loads. Can somebody please tell me where am I going wrong.
<apex:page standardController="Reservation__c" extensions="CarSharingClass">

<apex:commandButton value="Show Fahrzeuge"  action="{!showPanel}" / >

// I want to show the table only when the button is clicked.

<apex:pageBlockTable value="{!myCust}" var="showFahr" rendered="{!If(myCust != null && myCust.size>0 && isRendered==true ,true,false)}"  >
</apex:pageBlockTable>

</apex:page>
Class
public class CarSharingClass {

 public PageReference showPanel(){
        isRendered = true;
        
        return null;
    }
    public List<Fahrzeuge__c> getMyCust() { 

}

}


 
bob_buzzardbob_buzzard
It is being called because it is a getter for a value on the page. Your markup of '{!myCust}' translates server side to invoking 'getMyCust', so in order to render the page the VF engine has to invoke your method.
Shravya Rama 9Shravya Rama 9
Is there anyother alternative not to call that method in the begining.