tsdoc
    Preparing search index...

    Function response

    • Receive an Ajax response from the server.

      Usage:

      faces.ajax.response(request, context);

      Implementation Requirements:

      This function must evaluate the markup returned in the request.responseXML object and perform the following action:
      • If there is no XML response returned, signal an emptyResponse error. If the XML response does not follow the format as outlined in Appendix A.3 "XML Schema Definition For Partial Response" of the Jakarta Faces Specification Document signal a malformedError error. Refer to Jakarta Faces Specification Document section 13.3.6.3 "Signaling Errors".
      • If the response was successfully processed, send a success event as outlined in Jakarta Faces Specification Document section 13.3.5.3 "Sending Events".

      Update Element Processing

      The update element is used to update a single DOM element. The "id" attribute of the update element refers to the DOM element that will be updated. The contents of the CDATA section is the data that will be used when updating the contents of the DOM element as specified by the <update> element identifier.
      • If an <update> element is found in the response with the identifier jakarta.faces.ViewRoot:
        <update id="jakarta.faces.ViewRoot">
            <![CDATA[...]]>
        </update>
        Update the entire DOM replacing the appropriate head and/or body sections with the content from the response.
      • If an <update> element is found in the response with an identifier containing jakarta.faces.ViewState:
        <update id="<VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>jakarta.faces.ViewState<SEP><UNIQUE_PER_VIEW_NUMBER>">
           <![CDATA[...]]>
        </update>
        locate and update the submitting form's jakarta.faces.ViewState value with the CDATA contents from the response. <SEP> is the currently configured UINamingContainer.getSeparatorChar(). <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return from UIViewRoot.getContainerClientId() on the view from whence this state originated. <UNIQUE_PER_VIEW_NUMBER> is a number that must be unique within this view, but must not be included in the view state. This requirement is simply to satisfy XML correctness in parity with what is done in the corresponding non-partial Faces view. Locate and update the jakarta.faces.ViewState value for all Faces forms covered in the render target list whose ID starts with the same <VIEW_ROOT_CONTAINER_CLIENT_ID> value.
      • If an update element is found in the response with an identifier containing jakarta.faces.ClientWindow:
        <update id="<VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>jakarta.faces.ClientWindow<SEP><UNIQUE_PER_VIEW_NUMBER>">
           <![CDATA[...]]>
        </update>
        locate and update the submitting form's jakarta.faces.ClientWindow value with the CDATA contents from the response. <SEP> is the currently configured UINamingContainer.getSeparatorChar(). <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return from UIViewRoot.getContainerClientId() on the view from whence this state originated. <UNIQUE_PER_VIEW_NUMBER> is a number that must be unique within this view, but must not be included in the view state. This requirement is simply to satisfy XML correctness in parity with what is done in the corresponding non-partial Faces view. Locate and update the jakarta.faces.ClientWindow value for all Faces forms covered in the render target list whose ID starts with the same <VIEW_ROOT_CONTAINER_CLIENT_ID> value.
      • If an update element is found in the response with the identifier jakarta.faces.Resource:
        <update id="jakarta.faces.Resource">
           <![CDATA[...]]>
        </update>
        append any element found in the CDATA contents which is absent in the document to the document's head section.
      • If an update element is found in the response with the identifier jakarta.faces.ViewHead:
        <update id="jakarta.faces.ViewHead">
           <![CDATA[...]]>
        </update>
        update the document's head section with the CDATA contents from the response.
      • If an update element is found in the response with the identifier jakarta.faces.ViewBody:
        <update id="jakarta.faces.ViewBody">
           <![CDATA[...]]>
        </update>
        update the document's body section with the CDATA contents from the response.
      • For any other <update> element:
        <update id="update id">
           <![CDATA[...]]>
        </update>
        Find the DOM element with the identifier that matches the <update> element identifier, and replace its contents with the <update> element's CDATA contents.

      Insert Element Processing

      • If an <insert> element is found in the response with a nested <before> element:
        <insert>
            <before id="before id">
               <![CDATA[...]]>
            </before>
        </insert>
        • Extract this <before> element's CDATA contents from the response.
        • Find the DOM element whose identifier matches before id and insert the <before> element's CDATA content before the DOM element in the document.
      • If an <insert> element is found in the response with a nested <after> element:
        <insert>
            <after id="after id">
               <![CDATA[...]]>
            </after>
        </insert>
        • Extract this <after> element's CDATA contents from the response.
        • Find the DOM element whose identifier matches after id and insert the <after> element's CDATA content after the DOM element in the document.

      Delete Element Processing

      • If a <delete> element is found in the response:
        <delete id="delete id"/>
        Find the DOM element whose identifier matches delete id and remove it from the DOM.

      Element Attribute Update Processing

      • If an <attributes> element is found in the response:
        <attributes id="id of element with attribute">
           <attribute name="attribute name" value="attribute value">
           ...
        </attributes>
        • Find the DOM element that matches the <attributes> identifier.
        • For each nested <attribute> element in <attribute>, update the DOM element attribute value (whose name matches attribute name), with attribute value.

      JavaScript Processing

      • If an <eval> element is found in the response:
        <eval>
           <![CDATA[...JavaScript...]]>
        </eval>
        • Extract this <eval> element's CDATA contents from the response and execute it as if it were JavaScript code.
      • If a CSP nonce attribute is present on the <script> element that corresponds to the jakarta.faces:faces.js resource, for example:
        <script
            src=".../jakarta.faces.resource/faces.js?ln=jakarta.faces"
            nonce="...">
        </script>
        • Extract this CSP nonce attribute and apply it when executing the JavaScript code so that the browser permits execution.
        • This CSP nonce attribute should also be applied when executing the JavaScript code found in other response elements, such as <update>, <insert> and <extensions>.

      Redirect Processing

      • If a <redirect> element is found in the response:
        <redirect url="redirect url"/>
        Cause a redirect to the url redirect url.
      • Error Processing

      • If an <error> element is found in the response:
        <error>
           <error-name>..fully qualified class name string...<error-name>
           <error-message><![CDATA[...]]><error-message>
        </error>
        Extract this <error> element's error-name contents and the error-message contents. Signal a serverError passing the errorName and errorMessage. Refer to Jakarta Faces Specification Document section 13.3.6.3 "Signaling Errors".

      Extensions

      • The <extensions> element provides a way for framework implementations to provide their own information.

      Parameters

      • request: XMLHttpRequest

        The XMLHttpRequest instance that contains the status code and response message from the server.

      • context: { onerror?: Function; onevent?: Function; sourceid?: string }

        An object containing the request context, including the following properties: the identifier of the source element, per call onerror callback function, and per call onevent callback function.

      Returns void

      If request contains no data.

      2.0