How to pass a parameter from js to Apex through visual force page?

Frank
1 min readAug 22, 2020

In the Apex class, to get a parameter from a visual page is very easy, firstly, let’s have a look at how to pass a parameter in the Http request in js:

window.open('/apex/ExportRepaymentDetails?id=xxxx&type=create');

Then forward the parameter to the Apex class in the visual page according to the following way:

<apex:page controller="RepaymentDetails" action="{!InitParameter}" renderAs="pdf">// ...
</apex:page>

Then get the parameter in Apex class, as the following code:

public class RepaymentDetails {
private static string Id = '';
private static string Type = ''; // ..... public static void InitParameter() { Id = ApexPages.CurrentPage().getParameters().get('id'); Type = ApexPages.CurrentPage().getParameters().get('type'); } // ........
}

--

--

Frank
0 Followers

A C/C++ programmer has a strong curiosity with new technology (e.g. Go, Dart, Apex).