I'm trying to do something fairly simple, display a value from a Map<String, Decimal>. When I do, though, I get the following error message:
Unknown property 'BigDecimal.test'
Error is in expression '{!SUMQTYCost['test']}' in component <apex:page> in page testpage
Error evaluating dynamic reference 'test'
The tag which causes this error is {!SUMQTYCost['test']}
, regardless of where it appears in the page, whether it's in the value attribute of an apex:OutputText tag or just in the text of the page.
SUMQTYCost is declared as:
public map<string, decimal> SUMQTYCost { get; set; } //Map of CostCenter (api name) to total cost for that CostCenter
I have a method which populates SUMQTYCost which is called toward the beginning of the controller's constructor. For testing purposes, I added the following code to the end of that method:
SUMQTYCost.put('test', 9999);
system.debug(SUMQTYCost);
The debug log shows {Analytical=0.00, Disposal=0.00, Permits & Fees=0.00, Rental Equipment=0.00, Subcontractor=0.00, test=9999}
.
When I try to open the VF page, The error message indicates it's trying to pull the value from BigDecimal.test which clearly doesn't exist. If I change the quoted value in the page 'test' to 'somethingElse', the error changes to BigDecimal.somethingElse. This happens even if I DON'T update the quoted value in the controller. This rules out anything related to the map not containing the key.
When I first encountered this, I was trying to use {!SUMQTYCost[i]} (i is the var for a pageBlockTable that parents this. The error would show for BigDecimal.Analytical. 'Analytical' happens to be the value of the first element in the list I'm iterating through.
Is there a way to get it to treat this as a Map<String, Decimal> rather than trying to dynamically call non-existent properties on some other kind of random datatype?