+ Start a Discussion
King KooKing Koo 

Pass parameters to controller on page load from VF

Hi guys

I have an Account page layout, and there are 2 sections inside the page layout for 2 VF pages that I have.

The subject for the first is "Apple", and the subject for the second is "Orange".

Both are using the same controller extension.

Based on the subject, the controller extension will pull different records from another custom object, so in the Apple section, it's showing my VF page called Apple_Page that shows information about apples, and in the Orange section, it's showing my VF page called Orange_Page that shows information about oranges.

I thought there would be a way for me to pass a parameter on page load of these two VF pages to the controller extension so that the controller extension can retrieve the proper records.

What exactly can I do?  I tried actionSupport, actionFunction, but none of them seem to really work.  All I want to do is for the Apple_Page to pass a string "apple" on page load to controller extension, and for Orange_Page to pass the string "orange" on page load to the same controller extension.

I thought it would be easy, but I have already spent 5 hours on it today and I think by now I need some help.

Thanks a lot
Hello King,

I would suggest you to use java script for this. In JS you can use onLoad event and catch in VF.

Example: https://developer.salesforce.com/forums?id=906F0000000957DIAQ

Refer: https://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm
Damien Phillippi033905702927186443Damien Phillippi033905702927186443
The other solution probably won't work because even though they use the same controller, they are still using 2 different instances of this controller.  The only way I can think of to accomplish what you want is to passing the data you want in the the Page parameters.  Be careful when you do this because it can cause some security holes if done improperly.  Something like:

Apex:pages.currentPage.getParameters().put('apple', appleVal);