You need to sign in to do that
Don't have an account?

Declare Static Resource as a variable to assign its value through commandbutton
Hello,
I have the following code:
What I am trying to fix is that I do not want a "hard copy" image for my icon: URLFOR($Resource.ms_star)
I want to be a variable, sth like: URLFOR($Resource.imageVar)
Then with a command Link I would assign a specific value (the name of the image inside the static resource) to that variable:
So far I figured that "imageVar" has to be a variable in my class so I tried:
*Static Resource named imageVar does not exist. Check spelling.*
I have the following code:
<apex:mapMarker position="{!war.GeoLocPosition__c}" title="{!war.Name}" icon="{!IF(war.AE_letzte_12_Monate__c > 5000,URLFOR($Resource.ms_star), IF(war.AD_MS_Rel_Anzahl_bez__c <= currentAccount.AD_MS_Rel_Anzahl_bez__c && war.WirtschaftszweigWZ08__c = currentAccount.WirtschaftszweigWZ08__c && war.Mitarbeiternzahl_final__c = currentAccount.Mitarbeiternzahl_final__c,URLFOR($Resource.perfect_fit), IF(war.Accountinhaber_Text__c= 'JOB SHOP',URLFOR($Resource.shop), URLFOR($Resource.ms_marker))))}">
What I am trying to fix is that I do not want a "hard copy" image for my icon: URLFOR($Resource.ms_star)
I want to be a variable, sth like: URLFOR($Resource.imageVar)
Then with a command Link I would assign a specific value (the name of the image inside the static resource) to that variable:
<apex:commandLink action="{!setCenter}" value="{!war.ShippingStreet} ,{!war.ShippingPostalCode} {!war.ShippingCity}" reRender="geomap"> <apex:param name="image" value="green" assignTo="{!imageName}"/></apex:commandLink>
So far I figured that "imageVar" has to be a variable in my class so I tried:
Public string imageName {get;set;}And in my visualforce page:
<apex:page standardcontroller="Account" extensions="FindNearbyController" docType="html-5.0" lightningStylesheets="true" action="{!findNearby}"> <apex:variable var="imageVar" value="{!imageName}"/>What am I am hoping to achieve is that the commandLink passes the value "green" to the variable "imageName" which then gets used as Static Resource for my icon. Obviously there is an png called "green" in my static resource. However I don't get the syntax right for the variable inside the URLFOR. I am receiving:
*Static Resource named imageVar does not exist. Check spelling.*
which did the trick. Then I assigned via the commandLink the new image which is also part of the zip file: