0

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.

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

1 Answer 1

2

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .