@TobyKutler It makes me change the class to this
and I updated the apex page to this <apex:commandButton image="{!URLFOR(imageUrl)}" onClick="RatingChange()" /></apex:column>but when saving the apext page its saying "Error: Unknown property 'Audit_Report__cStandardController.imageUrl'"public without sharing class ChangeColorController {
public ChangeColorController(ApexPages.StandardController controller) {
}
integer clickCount = 0;
string imageUrl;
List<StaticResource> green = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingGreen'];
List<StaticResource> yellow = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingYellow'];
List<StaticResource> red = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingRed'];
List<StaticResource> grey = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingGrey'];
List<StaticResource> blank = [SELECT Id, Body FROM StaticResource WHERE Name = 'RatingBlank'];
public ChangeColorController(){
imageUrl = blank[0].Body.toString();
}
public void RatingChange()
{
clickCount++;
if(clickCount == 1){
imageUrl = green[0].Id;
}
else if(clickCount == 2){
imageUrl = yellow[0].Id;
}
else if(clickCount == 3){
imageUrl = red[0].Id;
}
else if(clickCount == 4){
imageUrl = grey[0].Id;
}
else if(clickCount == 5){
imageUrl = blank[0].Id;
}
}
}
11 answers