部分更新のキャンセル

/***
 * Cancel Partial Refresh
 *
 * Function cancels a partial refresh and prevents client to refresh the DOM tree.
 * Thanks to Philippe Riand for his assistance!
 *
 * @author Sven Hasselbach
 *
 ***/
 
function cancelPartialRefresh(){
   var response = facesContext.getExternalContext().getResponse();
   response.setHeader("X-XspRefreshId", "@none");
   response.reset();
   response.commitResponse();
   facesContext.responseComplete();
}





使い方に関しては次のサンプルを参照してください。

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
 <xp:button value="Label" id="button1">
    <xp:eventHandler event="onclick" submit="true"
       refreshMode="partial" refreshId="label1">
    </xp:eventHandler>
 </xp:button>
 <xp:br/><xp:br/>
 <xp:label id="label1">
    <xp:this.value>
    <![CDATA[#{javascript:
    function cancelPartialRefresh(){
       var response = facesContext.getExternalContext()
          .getResponse();
       response.setHeader("X-XspRefreshId", "@none");
       response.reset();
       response.commitResponse();
       facesContext.responseComplete();
    }

    var ajax = new com.ibm.xsp.ajax.AjaxUtil();
    if( ajax.isAjaxPartialRefresh(facesContext) == true){
       cancelPartialRefresh();
       return; // stop execution of SSJS code
    }
    java.lang.System.currentTimeMillis();}]]>
    </xp:this.value>
 </xp:label>
</xp:view>

JavaScript (Server)
katoman
July 21, 2015 2:12 PM
Rating
0





No comments yetLogin first to comment...