2

I am working with a VF page that uses javascript remoting to do some work that an earlier developer made. There won't be an easy way to move the remoted method into the controller as a normal method that I can access through the page because it is used all over the place on other pages and has some pretty 'waiting to finish' messages built into the javascript as well.

The problem I have is that I need to get the ApexPages.currentPage().getParameters() to be accessible here. I cannot grab specific values to pass into the method either because the parameters will be dynamic. Is there any way to do this or is my only option to do all of the work to no longer use remoting?

1 Answer 1

3

@dphil Your going to have to pass the current page to the @RemoteAction, because these methods are global they do not have context with the controller they are a part of, as the ApexPages class does.

8
  • I can actually pass the current page into it? What would that look like?
    – dphil
    Jun 5, 2015 at 18:34
  • Could I just use {!$currentpage.parameters} and would that convert to a Map in the apex side?
    – dphil
    Jun 5, 2015 at 18:35
  • Dereference the current page in the page's markup via Visualforce and use it as an argument in the JS call. Off hand not sure what the formatting of the {!$currentPage.parameters} looks like in VF Jun 5, 2015 at 18:36
  • 1
    Yeah, looks like: myJSFunction('{!$currentPage.parameters}') (obviously a simplified way of calling it...) Jun 5, 2015 at 18:39
  • Whenever I try to save, I get the error: "problem": "Field parameters does not exist. Check spelling.",
    – dphil
    Jun 5, 2015 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .