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
rm1rm1 

Dynamic Reference to Static Resource causes a Syntax error

According to the VisualForce documentation here, you should be able to add a dynamic reference to a static resource.

The documentation provides this example:

 

"A very simple example of actual use on a page would be <apex:image value="{!$Resource[customLogo]}"/>, where you have a getCustomLogo method that returns the name of an image uploaded as a static resource."

 

This doesn't seem to work.

 

Here is my controller method:

public String getCustomLogo(){
return 'CompanyLogo';
}

 

and here is the line from my vf page:

<apex:image value="{!$Resource[CustomLogo]}"/>

 

I get the following error when trying to save the vf page:

 

Error: Syntax error. Found '$Resource'


How can I get this to work?

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

This is a Spring 12 feature.  Are you testing on an instance that has Spring 12?

All Answers

aballardaballard

This is a Spring 12 feature.  Are you testing on an instance that has Spring 12?

This was selected as the best answer
rm1rm1

Thanks.  I didn't realize the documentation was for Spring 12.  I am not on Spring 12.