I'm outputting a list of Opportunites and want to create a hash, or checksum for some of the data in the object. Is there a way to pass the current apex:repeat object back to the controller to get it to process the fields?

I'm thinking I need to go the Dynamic Component route, to manually output the table, looping over the Opportuinites in controller code, adding the checksum at that point. I'd like to be able to pass from visualforce back to the controller though, like a custom utility function.

  • 1
    What's the purpose of this checksum? It's probably easier accomplished via a wrapper object. – David Reed Oct 25 '19 at 20:45
  • @DavidReed what’s a wrapper object? Got a link? Sounds like a solution. – Dave Smith Oct 25 '19 at 20:49

A more typical Visualforce pattern is to iterate not over Opportunities, but over some wrapper object, an Apex class that encapsulates an Opportunity alongside those data points you wish to add to the native sObject fields. For example,

public class MyWrapper {
    Opportunity o { get; set; }
    Integer checksum { get; set; }

Your Visualforce code then receives all pertinent information (in, say, a List<MyWrapper>) and can access it directly, no complex dynamic code required.

  • This sounds like the perfect answer! I’m going to mark it, and try it later. Thanks! – Dave Smith Oct 25 '19 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.