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'); } // ........
}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Frank
Frank

Written by Frank

0 Followers

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

No responses yet

Write a response