第三十五講:tapestry Ajax zone組件無黃色閃爍的背景

實現方法很簡單,在zone組件里加上t:update="show"就不會出現黃色背景了。源碼以下:html

ZoneWithoutYellowHighlight.javajava

/**
 * 項目名稱:TapestryStart
 * 開發模式:Maven+Tapestry5.x+Tapestry-hibernate+Mysql
 * 網址: http://www.flywind.org
 * 版本: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 ZoneWithoutYellowHighlight {
 
@Inject
private Request request;
 
@InjectComponent
private Zone time2Zone;
 
void onActionFromRefreshPage(){}
 
Object onActionFromRefreshZone(){
return request.isXHR()?time2Zone.getBody():null;
}
 
public Date getServerTime1(){
return new Date();
}
 
public Date getServerTime2(){
return new Date();
}
}
 

ZoneWithoutYellowHighlight.tmlsql

<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" t:update="show">
serverTime2:  ${serverTime2}
</t:zone><br/>
</div>
</html>
相關文章
相關標籤/搜索