JSF非AJAX提交与"@all"提交之间的任何重大技术差异. AJAX提交? [英] Any significant technical difference between JSF non-AJAX submit and a "@all" AJAX submit?

查看:107
本文介绍了JSF非AJAX提交与"@all"提交之间的任何重大技术差异. AJAX提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JSF 2.0中,进行非AJAX提交(例如,并提交"@all" AJAX,例如?

用户不会从AJAX样式的提交中看到页面刷新,但是在技术上还有其他重大变化吗?提交给服务器的数据更少了吗? ASFAX和非AJAX提交的JSF生命周期的任何元素是否有所不同?

解决方案

从技术上讲,@all比同步回发要慢.渲染响应期间的HTML渲染没有区别,但是ajax响应中的数据略多,因为ajax响应是作为XML文档发送的,而更新的HTML作为CDATA块.以下数据被添加到整个HTML输出顶部的响应中:

 <?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>
 

(您可以在Chrome/Firebug/IE9中的Web开发人员工具集的网络"或网络"部分中自行查看,您可以通过按F12键来获得它)

因此,它总是比同步响应多〜250个字节.另外,由于JavaScript必须从XML响应中解析出所有HTML并替换为DOM,因此后期处理中会有一些开销,尽管如今使用快速机器对性能的影响几乎可以忽略不计.

但是,实际上,@all 出现在视觉上比同步回发更快,因为没有任何内容刷新" .

请注意,@all在PrimeFaces中长期以来不受支持,因为它根本上是错误的"(引用PrimeFaces线索),但是在

The user won't perceive a page refresh from the AJAX-style submit, but is anything else technically significant happening? Is less data being submitted back to the server? Are any elements of the JSF life-cycle different with the AJAX versus non-AJAX submit?

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.

这篇关于JSF非AJAX提交与"@all"提交之间的任何重大技术差异. AJAX提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆