Java Platform, Enterprise Edition (Java EE) 8 The Java EE Tutorial

## Receiving an Ajax Response

After the application sends an Ajax request, it is processed on the server side, and a response is sent back to the client. As described earlier, Ajax allows for partial updating of web pages. To enable such partial updating, JavaServer Faces technology allows for partial processing of the view. The handling of the response is defined by the `render` attribute of the `f:ajax` tag.

Similar to the `execute` attribute, the `render` attribute defines which sections of the page will be updated. The value of a `render` attribute can be one or more component `id` values, one of the keywords `@this`, `@all`, `@none`, or `@form`, or an EL expression. In the following example, the `render` attribute identifies an output component to be displayed when the button component is clicked (the default event for a command button):

    <h:commandButton id="submit" value="Submit">
        <f:ajax execute="userNo" render="result" />
    </h:commandButton>
    <h:outputText id="result" value="#{userNumberBean.response}" />

Note: Behind the scenes, once again the `jsf.ajax.request()` method handles the response. It registers a response-handling callback when the original request is created. When the response is sent back to the client, the callback is invoked. This callback automatically updates the client-side DOM to reflect the rendered response.

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.