`
hereson2
  • 浏览: 458393 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Ajax Integration with JSF 2.0

阅读更多
Ajax Integration with JSF 2.0
In JSF 2.0, An Ajax engine will be implemented on the client side. It will be responsible for the following:
    1. Sending an Ajax request to the server.
    2. Receiving the partial response then updating or inserting new element(s) in the client DOM.

At the client, the Ajax engine (which will be represented in the (Ajax.js) file) will construct the Ajax request which will contain the following:
    1. The name and value of the source element that triggers the Ajax request.
    2. A single parameter that says that this request is an Ajax request. This parameter is called (javax.faces.ajax.partial) and its value is set to true.
    3. The encoded view state.
    4. The set of client ids that must be processed in the partial view execute phases, and the set of client ids that must be processed in the partial view render phase.

At the server, the request will be recognized whether it is an Ajax request or not by checking the (javax.faces.ajax.partial) request parameter. If it is an Ajax request, a partial view execute and a partial view render will be applied on the components sent in the Ajax request (check the previous step 4). Finally the server will generate the content data in a language understandable by the client (may be XML or JSON).

At the client, the Ajax client engine will receive the server response, and would interpret it to know whether to update or insert new elements to the DOM.

Notes:
    1. The FacesContext.isAjaxRequest() method can be used to check whether the current request is an Ajax request or not.
    2. All of the Ajax engine requests should be asynchronous, and to ensure their correct execution order, the request will be enqueued (once the component initiate it) and dequeued (once the request completed execution) from a request queue.

A simple example to illustrate the idea (From the JSF 2.0 specs ED2):
<h:commandbutton id="submit" value="submit"
onclick="javax.faces.ajax.ajaxRequest(this, event,

转自:http://www.jroller.com/HazemBlog/entry/ajax_integration_with_jsf_2
{execute:'submit',render:'outtext'}); return false;" />
This will execute the partial view execute on the ‘submit’ button and the partial view render on the ‘outtext’ component at the end.

Finally, I would like to mention that the script resources in JSF 2.0 are relocatable meaning that you can control their encoding place by setting the target attribute of the resource component. The @ResourceDependency annotation can be also used before the component renderer class to achieve the same functionality.
分享到:
评论

相关推荐

    Mojarra JSF2.0库文件

    **JSF 2.0(JavaServer Faces 2.0)**是Java平台上的一种服务器端的用户界面框架,用于构建富互联网应用程序(Rich Internet Applications,RIA)。它遵循MVC(Model-View-Controller)设计模式,提供了一种声明式的...

    JSF2.0源代码

    7. **Ajax增强**:JSF 2.0提供了内置的Ajax支持,通过`&lt;f:ajax&gt;`标签和`javax.faces.behavior.ajax`注解,简化了异步更新。 **三、Mojarra源代码分析** 通过查看源代码,我们可以深入了解以下关键组件: 1. **...

    jsf2.0版本helloworld

    本例中的"jsf2.0版本helloworld"就是一个基础的入门示例,旨在展示如何在MyEclipse环境中配置和运行一个简单的JSF应用。 **JSF 2.0的关键特性** 1. **Faces Flow**: JSF 2.0引入了Faces Flow,这是一种新的导航模型...

    JSF2.0实战 - 10、自定义Ajax更新方式

    在JSF 2.0中,Ajax功能的引入极大地增强了用户界面的交互性和实时性。这一部分我们将深入探讨如何实现自定义的Ajax更新方式,以更灵活地控制UI组件的异步更新。在这个主题中,我们将关注以下几个关键知识点: 1. **...

    jsf 2.0 api和imp的jar包+源码包+doc

    JSF 2.0是其一个重要版本,带来了许多改进和新特性,使得开发更加高效且易于维护。这个压缩包包含了JSF 2.0的API jar包、实现库(即impl jar包)、源码以及doc帮助文档,为深入理解和学习JSF提供了全面的资源。 API...

    jsf2.0实例

    文档《JSF2.0系列简介.doc》可能详细介绍了JSF 2.0的基础知识和实践指导,而压缩包中提供的源代码可能是为了演示如何在实际项目中使用JSF 2.0。这些示例可能涵盖了以下内容: - **创建基本的JSF页面**:展示如何...

    JSF2.0实战 - 6、TextBox

    在本篇中,我们将深入探讨JSF 2.0中的TextBox组件,它是用户界面中用于输入文本的基础元素。JSF(JavaServer Faces)是Oracle公司提供的一个用于构建Web应用程序的MVC框架,而JSF 2.0版本带来了许多改进和新特性,使...

    JSF2.0标签手册

    JSF2.0标签手册DQSV

    JSF2.0与Ajax交互实现.pdf

    ### JSF 2.0与Ajax交互实现 #### 核心知识点概述 1. **JSF 2.0**: JavaServer Faces (JSF) 是一个用于构建基于组件的用户界面的标准Java框架。JSF 2.0是JSF的一个重大更新版本,提供了更简洁的API、增强的功能以及...

    jSF2.0与Spring整合实例+教程

    **JavaServer Faces 2.0 (JSF 2.0) 和 Spring 框架的整合教程** 在当今的企业级Web开发中,JSF 2.0 和 Spring 的结合使用非常常见,因为它们各自提供了独特的优势。JSF 是一个用于构建用户界面的组件模型框架,而 ...

    JSF 2.0 (Mojarra 2.0.2-FCS)

    JSF 2.0引入了全双工通信模型,通过Ajax Push技术(例如PrimeFaces的Push API),允许服务器主动向客户端推送数据,提升了实时应用的开发能力。 4. **异步请求处理**: 新增了`&lt;f:ajax&gt;`标签,支持异步请求,使得...

    jsf 2.0官方参考手册

    JSF 2.0支持AJAX,允许部分页面更新,提高了用户体验。Partial State Saving机制只保存当前交互所需的最小状态,减少了服务器端的内存消耗。 **六、导航系统** JSF 2.0提供了强大的导航系统,允许根据用户操作和...

    Jsf2.0 Refrence

    在"Jsf2.0 Reference"中,我们能够深入理解JSF的核心概念和技术,这包括但不限于以下几个方面: 1. **JSF生命周期**:JSF组件有其独特的生命周期,包括六种阶段:恢复视图、应用请求值、处理验证、更新模型值、调用...

    JSF 2.0 开发资料

    - **AJAX 支持**:JSF 2.0 提供了内置的 AJAX 支持,无需额外的 JavaScript 或 jQuery 知识,即可实现异步数据交互,提高了用户体验。 - **事件监听器**:简化了事件处理机制,可以使用注解或方法签名直接定义...

    JSF2.0_开发入门

    - Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6 - 由知名的作者和开发者 Marty Hall 授课。 - 可以根据需求选择不同的课程组合,如专注于特定技术...

    JSF2.0 开发简介

    JSF 2.0 的核心目标是简化Web应用程序的开发,通过引入新特性,如注解配置、流线化的导航以及Ajax支持,使其成为更强大、更易用的框架。 **1. 注解配置:去除XML配置** 在JSF 2.0中,开发人员可以通过注解而不是XML...

    jsf2.0 tutorial.rar

    JSF 2.0支持AJAX,允许部分页面更新,提升了用户体验。通过使用f:ajax标签或PrimeFaces等库,可以轻松实现异步交互。 10. **会话和状态管理** JSF管理会话状态,确保用户在会话期间保持一致的体验。JSF 2.0提供了...

Global site tag (gtag.js) - Google Analytics