A developer is using a third-party JavaScript library to create a custom user interface in Visualforce. The developer needs to use JavaScript to get data from a controller method in response to a user action. How can the developer accomplish this?
A.
Use <apex:actionFunction> to create a JavaScript wrapper for the controller method
B.
Use the @RemoteAction annotation on the method definition with JavaScript Remoting
C.
Use the $Controller global variable to access the controller method via JavaScript
D.
Use <apex:actionSupport> to enable JavaScript support for the controller method
B. Use the @RemoteAction annotation on the method definition with JavaScript Remoting.
JavaScript Remoting: By using the @RemoteAction annotation, a static controller method can be invoked directly from JavaScript. This allows the integration of third-party JavaScript libraries with Visualforce.
Asynchronous Calls: JavaScript Remoting supports asynchronous calls with callback functions, providing a responsive user experience when the controller method is called in response to user actions.
Simplicity: This approach avoids the need to wrap the controller method in an <apex:actionFunction> or <apex:actionSupport>, which are more tightly coupled to Visualforce components.
Answer B Javascript remoting is correct as actionSupport does not provide javascript support. It calls the controller method directly for the selected user action.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
vancika
1 month agoajithk47
8 months, 2 weeks agoGGJJ
8 months, 4 weeks agoBrainMelt12
1 month, 2 weeks agolorenac2
10 months, 1 week ago