2

I am trying to show territory details and calculate few variables in same page on click of territory in Map.

For that, I need to use values which are stored in javascript variable to pass into Apex method.

Any ideas will be appreciated

Please help me.

  • 3
    You've tagged it with javascript remoting, which sounds indeed the way to go. Have you already tried that ? If you need a start of point: salesforce.com/us/developer/docs/pages/Content/… – Samuel De Rycke Dec 19 '13 at 9:15
  • I know that we can access apex method in visualforce through javascript remoting. but can we do vice-versa..??? – Arun SFDC Dec 19 '13 at 9:49
  • not entirely sure what you mean by that. Maybe you can update your question with a more detailed process explanation of what you're trying to achieve. JS remoting isn't the only option. – Samuel De Rycke Dec 19 '13 at 9:57
2

Vice-Versa. You mean directly access JavaScript variables from within the body of Apex methods in your Controller without passing them in somehow? That's not possible.

However, Passing them into an Apex method as parameters is possible with JavaScript Remoting. Example here. If you have many, you can always create an Apex class and fill an instance of it in your JavaScript with all of the values you want and pass it. See this question and answers.

  • Also, actionFunction tags can access view state, which is sometimes more appropriate. JavaScript remoting doesn't give you view state access. – sfdcfox Dec 19 '13 at 16:45
0

For This , You can use hidden field -with getter setter values, where ever you are assigning the values to variable ,set hidden field values to variable js...call action function.

0

I would take a look at this post, and also the comments - see Dave Carroll's link to an alternative method

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.