You need to sign in to do that
Don't have an account?
How to access class variables from a Java RemoteMethod
Maybe someone can can help me out with this logic to access variables from outside of a remote Method
Say I have my controller as follows Sudo code,
global with sharing class myController {
public Map<String, String> myMap {get; set;}
public myController() {
Populate myMap with values
}
@RemoteAction
global Static String returnStrValue(String keyStr) {
String value = myMap.get(keyStr);
return value;
}
}
// NOW on my VF page
I would call upon my javaremote method to return a map value when a given key is supplied which i have in my javascript
The problem that im having and i know is that the variables created in my controller are not accesible from my remote method, im thinking maybe querying the MAP in my VF and assigning to a JS varaible then passing it back into my remote method so my remote method would look like this.
I havent got this way working yet as i dont think the MAP assisngs correctly to the JS variable, is there a better way to do this? Thanks
@RemoteAction
global Static String returnStrValue(String keyStr, Map<String, String>) {
String value = myMap.get(keyStr);
return value;
}
}
Hey ssfdc,
You could pass your map to a javascript function(suppose, remoting method is inside that function), then from that remoting method pass the map and the value to apex remote method. By this you don't have to additionally create the map again.
I'm not sure if you were referring to the same thing.