Any significant technical difference between JSF non-AJAX submit and a “@all” AJAX submit?

后端 未结 1 1573
慢半拍i
慢半拍i 2021-01-24 14:44

In JSF 2.0, is there any significant technical difference between doing a non-AJAX submit e.g. and a \"@all\" AJAX submit e.g. ?

The user won\'t perceive a page refres

相关标签:
1条回答
  • 2021-01-24 14:58

    Technically, @all is slower than a synchronous postback. There's no difference in the HTML rendering during render response, but there is slightly more data in the ajax response, because the ajax response is been sent as a XML document with the updated HTML as a CDATA block. The following data is added to the response on top of the entire HTML output:

    <?xml version='1.0' encoding='UTF-8'?>
    <partial-response>
        <changes>
            <update id="javax.faces.ViewRoot">
                <![CDATA[
                    HTML output here.
                ]]>
            </update>
            <update id="javax.faces.ViewState">
                <![CDATA[5778819104895950876:-4716773626508512118]]>
            </update>
        </changes>
    </partial-response>
    

    (you can see it yourself in "Net" or "Network" section of the web developer toolset in Chrome/Firebug/IE9 which you can get by pressing F12)

    That's thus always ~250 bytes more than a synchronous response. Also, there's some overhead in the postprocessing because JavaScript has to parse all that HTML out of the XML response and replace the DOM with it, although the performance impact is practically totally negligible these days with fast machines.

    However, in practice, @all appears visually faster than a synchronous postback because there's no means of any "flash of content".

    Note that @all was unsupported for long in PrimeFaces because it is "fundamentally wrong" (to cite the PrimeFaces lead), but after the OmniFaces FullAjaxExceptionHandler, the PrimeFaces lead has changed minds and it's supported from PrimeFaces 3.2 and on.

    0 讨论(0)
提交回复
热议问题