JSF之定时刷新

http://blog.sina.com.cn/s/blog_4e23b08f0100fevo.html

方法一:

在head中加入  <meta http-equiv="refresh" content="间隔秒数"/>

 

定时跳转至其他页面,可以用:
在head中加入  <meta http-equiv="refresh" content="间隔秒数" url="跳转页面"/>

 

方法二:未测试过,仅把原文转贴至此.

本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/guijava/archive/2009/01/14/3775298.aspx

用a4j:poll可以实现jsf页面定时刷新

下面是一个示例

<a4j:region>
   <h:form>
    <a4j:poll interval="2500" reRender="list"/>
   </h:form>
  </a4j:region>

其中,interval="2500"是多长时间刷新一次,单位是毫秒,示例中2.5秒刷一次

 reRender="list" 是刷新的内容,list是要刷新控件的id

ps:巧用两个a4j:poll控制刷新

示例如下

<a4j:region>
   <h:form>
    <a4j:poll id="list1" interval="2500" reRender="list"/>
   </h:form>
  </a4j:region>
  <a4j:region>
   <h:form>
    <a4j:poll id="list" interval="2500"
     enabled="#{socketInspectWindow.map['socketInspectTable'].refreshFlag}"
     actionListener="#{socketInspectWindow.refreshAction}"
      reRender="logInfo,importLogInfo,soundForm">
    </a4j:poll>
   </h:form>
  </a4j:region>

其中enabled="#{socketInspectWindow.map['socketInspectTable'].refreshFlag}"是一个boolean型变量,当需要刷新的时候refreshFlag变成true,actionListener="#{socketInspectWindow.refreshAction}"做的事情是当刷新完以后将refreshFlag改回false

基本原理是第一个poll一直在刷新第二个poll,第二个poll中一旦refreshFlag变成true时,就立即执行刷新


----------------------

http://blog.sina.com.cn/s/blog_4e23b08f0100fzoa.html

转载:Ajax4jsf使用a4j:poll实现定时刷新

  (2009-10-29 16:06:56)
标签: 

it

分类: JSF

http://wc-stone.javaeye.com/blog/230474

 

a4j:poll

常用属性:

  • interval 经过多少ms执行一次action
  • reRender 指定重新渲染哪些组件
  • rendered 指定重新渲染哪些组件
  • enabled 属性指定是否允许自动检测(即 a4j:poll 是否有效)
  • oncomplete 指定action完成后客户端要执行的js方法
Java代码

 

 



注意

  1. a4j:poll 必须嵌入到h:form内部,否则不起作用
  2. a4j:poll 会对整个form起作用,即每次刷新时, 同一form内的所有uim绑定属性都会发送请求,uim中的属性getter/setter方法会自行调用
  3. 同一form内,避免使用超过一个的 a4j:poll 定时器,如果在一个页面中需要多个定时刷新,则最好每个 a4j:poll 放在一个form中

  4. <h:form>
    <a4j:poll interval="10000" reRender="" />
    <a4j:outputPanel id="outputPanel">
       <t:inputText forceId="true" value="#{menuUim.keyword}"/>
    <a4j:outputPanel>
    </h:form>

    menuUim.keyword会被刷新一次,调用一次属性的getter/setter方法,但不会刷新页面显示值


    <h:form>
    <a4j:poll interval="10000" reRender="outputPanel" />
    <a4j:outputPanel id="outputPanel">
       <t:inputText forceId="true" value="#{menuUim.keyword}"/>
    <a4j:outputPanel>
    </h:form>

    menuUim.keyword会被刷新两次,调用两次属性的getter/setter方法,且会刷新页面显示值


    <h:form>
    <a4j:poll interval="10000" reRender="outputPanel" />
    </h:form>
    <a4j:outputPanel id="outputPanel">
       <t:inputText forceId="true" value="#{menuUim.keyword}"/>
    <a4j:outputPanel>

    menuUim.keyword会被刷新一次,调用一次属性的getter/setter方法,会刷新页面显示值




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值