开发手册 欢迎您!
软件开发者资料库

Apache Tapestry - Ajax组件

Apache Tapestry Ajax组件 - 从简单和简单的步骤学习Apache Tapestry,从基本到高级概念,包括概述,体系结构,安装,快速入门,项目布局,约定配置,注释,页面和组件,模板,组件,内置 - 在,表单和验证,Ajax组件,休眠,存储,高级功能。

AJAX代表异步JavaScript和XML .这是一种借助 XML,JSON,HTML,CSS, JavaScript 创建更好,更快,更具交互性的Web应用程序的技术. AJAX允许您在不重新加载网页的情况下异步发送和接收数据,因此速度很快.

区域组件

区域组件用于提供内容(标记)以及内容本身的位置. Tape Component内部使用Zone Component的主体来生成内容.生成动态内容后,Tapestry会将其发送到客户端,在正确的位置重新呈现数据,触发HTML动画并引起用户注意.

此区域组件与EventLink组件一起使用. EventLink可以选择使用 t:zone 属性将其绑定到特定区域.在EventLink中配置区域后,单击EventLink将触发区域更新.此外,EventLink事件(refreshZone)可用于控制动态数据的生成.

AJAX的一个简单示例如下 :

AjaxZone.tml

               

Ajax time zone example

                   Ajax Link 

          Time zone: ${serverTime}       
        

AjaxZone.java

package com.example.MyFirstApplication.pages;  import java.util.Date; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.Request;  public class AjaxZone {    @Inject    private Request request;       @InjectComponent    private Zone timeZone;       void onRefreshPage() {    }       Object onRefreshZone() {       return request.isXHR() ? timeZone.getBody() : null;    }       public Date getServerTime() {       return new Date();    } }

结果将显示在:http://localhost:8080/MyFirstApplication/AjaxZone

Ajax时区