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
AyanHoreAyanHore 

How to generate controller method name dynamically and invoke from Visualforce

Hi,

I've a rather "unique" condition which I'm trying to resolve and need help to do it. Below is the scenario:

I've a large number of data (>1000) which I need to display in a selectlist. I've implemented the same by breaking the list into lists of 1000 values each and have methods like: getValue0() -- which fetches the data for offset 0, getValue1() -- for offset 1 and so on... based on the volume of data, I'm calculating the offset and want to call those methods from the VF page. I want to do something like this:
Suppose I've 2500 records for the selectlist. So, dividing them in chunks of 1000 each gives me 3 offsets (0,1 and 2). So, I would like to call only getValue0(), getValue1() & getValue2() from the VF page. I've a apex repeat going on to loop for the total number of offsets and another variable initialized to 0. What I'm trying to do is combine the String: getValue and the variable count from the loop (0,1 and 2 in this case) to get the controller variable name dynamically and then invoke them within the repeat. I'm not able to do that and need help.

Could you please tell me if this is even possible? And if so, how can I do this?

Any help in this regard will be very helpful for me.

Regards,
~Ayan