/**
* 项目名称:TapestryStart
* 开发模式:Maven+Tapestry5.x+Tapestry-hibernate+Mysql
* 版本:1.0
* 编写:飞风
* 时间:2012-02-29
*/
package com.tapestry.app.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 AJAXActionLink {
@Inject
private Request reauest;
@InjectComponent
private Zone time2Zone;
void onActionFromRefreshPage(){}
Object onActionFromRefreshZone(){
return reauest.isXHR()? time2Zone.getBody():null;
}
public Date getServerTime1(){
return new Date();
}
public Date getServerTime2(){
return new Date();
}
}
<html t:type="layout" title="tapestryStart Index" t:sidebarTitle="Framework Version"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<div style="margin-left: 50px">
<a t:type="actionlink" t:id="refreshPage" href="#">ActionLink刷新页面</a><br/>
<a t:type="actionlink" t:id="refreshZone" href="#" t:zone="time2Zone">ActionLink AJAX无刷新</a><br/><br/>
serverTime1: ${serverTime1}
<t:zone t:id="time2Zone">
serverTime2: ${serverTime2}
</t:zone><br/>
</div>
</html>