Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
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

3 Answers 3

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.

share|improve this answer
    
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

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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