Component with AJAX Support | DEV-501 Exam Answer | Salesforce

Component with AJAX Support

Question

A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover.

See also: <apex:actionFunction>.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D.

The correct answer is D. apex:actionSupport.

Apex:actionSupport is a component in Visualforce that enables AJAX support in another component. This component allows a component to be refreshed asynchronously by the server when a specific event occurs, such as a button click or mouseover.

When a user performs an action that triggers an event, such as clicking a button, the apex:actionSupport component sends a request to the server using AJAX. The server then processes the request and sends back the updated data. The component that used apex:actionSupport then updates itself with the new data, without requiring a full page reload.

Here is an example of how to use apex:actionSupport:

php
<apex:page> <apex:form> <apex:inputText value="{!myText}" id="myTextId"> <apex:actionSupport event="onkeyup" action="{!updateText}" rerender="textBlock"/> </apex:inputText> </apex:form> <apex:outputPanel id="textBlock"> <apex:outputText value="{!myText}"/> </apex:outputPanel> </apex:page>

In this example, the apex:actionSupport component is added to an apex:inputText component. The event attribute is set to "onkeyup", which means that the AJAX request will be sent to the server every time the user types a key. The action attribute is set to a method called "updateText" in the controller. The rerender attribute is set to "textBlock", which means that the outputPanel with the id "textBlock" will be refreshed with the updated data from the server.

Overall, the apex:actionSupport component is a powerful tool for creating dynamic, responsive user interfaces in Visualforce.