function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jthor@entransform.comjthor@entransform.com 

listen to visual force page

Is there a way for a visual force page to execute something when it is called via page reference  in the controller?

Prafull G.Prafull G.
You can use "action" attribute for the <apex:page> tag to perform something on page load.
Give it a try or let me know if you are looking after to some specific action to be performed.

Thanks,
jthor@entransform.comjthor@entransform.com
Yeah I am looking for when the controller calls the page like this
apexpages.currentpage().getparameters().get("some parameter");
we have something in the visual force page that listens to this event and does something.
Prafull G.Prafull G.
Ok.
If you want to display or use the parameter value for some logic on visualforce page itself then probably you should use the following syntax
"{!$CurrentPage.parameters.Paramtervalue}" to get the parameter value of page and do logic accordingly.

if you want to do some processing in apex class (vf page contoller) then you can use the syntax you mentioned above.
jthor@entransform.comjthor@entransform.com

Thnx, but that not what I am looking for. I wanted to make a listener in my visual force page so that when the page is called by the controller it execute a javascript function in the visualforce page. Sorry I know my question is not that clear.

Prafull G.Prafull G.

You can use the same syntax in javascript as well. For example:

<script>

if("{!$CurrentPage.parameters.Paramtervalue}" == "ABC") {

  //call action/javascript method here

}

</script>

jthor@entransform.comjthor@entransform.com

Just to be clear the code excute when ever the parameter value changes right?

That means that someFunction() is executed whenever the parameter values ==  "ABC" 

<script>
if("{!$CurrentPage.parameters.Paramtervalue}" == "ABC") {
  //call action/javascript method here
someFunction() } </script>

 

Prafull G.Prafull G.
That's correct!

If you want to put some more logic then you can use nested if else statements to compare different parameter values and execute functions accordingly.

Regards,
-P
jthor@entransform.comjthor@entransform.com

Thank you. Once I get it working I will select the post as working.

jthor@entransform.comjthor@entransform.com

I mean acccept as solution.

Prafull G.Prafull G.
You can always Edit your reply once posted. Check the 'Options' (red color) menu on top right of every post.

Thanks,
P