You need to sign in to do that
Don't have an account?
Pass value to controller using Javascript in Visual Force
So, I am trying to start recycling my visual force pages/controllers by passing values in the URL string to determine some of the basic info in my cases instead of having individual pages/controllers for each circumstance. I have my javascript that reads the URL and I have my controller making the changes on the back end for each circumstance, now I have to connect the two but I am having a bit of a difficult time... any suggestions?
VF Javascript Code
<SCRIPT LANGUAGE="JavaScript"> var GETDATA = new Array(); var sGet = window.location.search; if (sGet) { sGet = sGet.substr(1); var sNVPairs = sGet.split("&"); for (var i = 0; i < sNVPairs.length; i++) { var sNV = sNVPairs[i].split("="); var sName = sNV[0]; var sValue = sNV[1]; GETDATA[sName] = sValue; } } if (GETDATA["PageConfigName"] != undefined){{!PageConfigName} = GETDATA["PageConfigName"];} </SCRIPT>
Apex Controller getter/setter code (not complicated lol)
public String PageConfigName{set;get;}
Thanks for your help in advance!!
What's the URL look like? You might be able to get these values directly to Apex with no javascript.
na3.salesforce.com/mypage?id=asdfasdf&name=John
Id objectId = ApexPages.currentPage().getParameters().get('id');
String firstName = ApexPages.currentPage().getParameters().get('name');
All Answers
What's the URL look like? You might be able to get these values directly to Apex with no javascript.
na3.salesforce.com/mypage?id=asdfasdf&name=John
Id objectId = ApexPages.currentPage().getParameters().get('id');
String firstName = ApexPages.currentPage().getParameters().get('name');
Thank you very much, that worked perfectly and is exactly what I was hoping for. I knew there had to be a way to do this without using javascript. You just saved me a ton of time and code.
Thanks!