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?

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.

  • I can actually pass the current page into it? What would that look like? – dphil Jun 5 '15 at 18:34
  • Could I just use {!$currentpage.parameters} and would that convert to a Map in the apex side? – dphil Jun 5 '15 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 – jordan.baucke Jun 5 '15 at 18:36
  • 1
    Yeah, looks like: myJSFunction('{!$currentPage.parameters}') (obviously a simplified way of calling it...) – jordan.baucke Jun 5 '15 at 18:39
  • Whenever I try to save, I get the error: "problem": "Field parameters does not exist. Check spelling.", – dphil Jun 5 '15 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.