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
OxeneOxene 

Extending the scope of static variable

I have a VF page and an extension class to extend the standard controller. I need to have a global variable in the apex class which keeps incrementing by 1 each time a particular function is accessed. As the scope of 'static' is limited to a request, i'm not able to track the count. Can anybody help?
JitendraJitendra
Hi Oxene,

i thing here you can use the custom object and you can save the counter in object and when function is accessed you increment the counter and update the object again.

OR

if you want to work only on page level then you can use this technique:

Code:
class Scope{
public Integer counter = 0;

public Integer getCOunter(){
return counter;
 }

public Scope getData(){
counter ++;
return <object of scope or whatever u are returning>
}


Then in VF page u can simply use {!counter}
no need of use static variable, as it will directly increase the counter variable and finally u will get the number of functions called.

 

OxeneOxene
Thanks Jitendra...