Salesforce - Static Resources

«« Previous
Next »»

The user interface in a Visualforce base can display dynamic content the value of which keeps changing based on user responses. But there are times when we need some content which should not change with the change in values of other components in the page. For example, an image file may be required to remain constant. Such content which cannot be changed in a page is known as a static resource.

Following are a few static resources in Salesforce −

◉ Images
◉ Javascript Files
◉ Flash files
◉ CSS files

The steps to create a static resource are as below.

Create a Static Resource container


Go to Develop → Static resource and mention the values for name, description and file location for the static resource.

Salesforce - Static Resources

Upload a Static Resource


Click Save in the above screen to get the file attached to the User Interface controller.

Salesforce - Static Resources

Reference the Static Resource


Next we create the apex code as in the following screenshot to reference the static object we created above.

Salesforce - Static Resources

Output


Running the above apex code will generate the following output. The output shows a static resource.

Salesforce - Static Resources

«« Previous
Next »»

No comments:

Post a Comment