2013-07-02 43 views
0

在我的頁面中,我有一個rich:datatable,它從輔助bean獲取數據。我想調用bean中的一個方法來刷新數據並刷新表格之後。刷新數據並在設置時間後調用backing bean方法

目前,我有以下的情況,但該方法被調用,但表保持未被刷新

<f:view> 
    <h:form> 
     <a4j:region> 
      <a4j:poll id="poll" interval="5000" action="#{attendance.updateData()}" enabled="true" reRender="poll,attendanceList"/> 
     </a4j:region> 
     <rich:dataTable width="500" id="attendanceList" reRender="scroller" 
      rows="#{attendance.getRows()}" columnClasses="attendance" 
      rowClasses="even-row, odd-row" 
      value="#{attendance.getData()}" var="a" 
      style="width:100%" rendered="#{attendance.renderAttendanceList}" 
      onbegin="waitCursor(true)" oncomplete="waitCursor(false)"> 

回答

1

通常情況下,我定義的動作在a4j:poll本身被稱爲:

<a4j:poll id="poll" interval="1800000" action="#{viewManagedBean.actionToBeCalled}" enabled="true" reRender="poll,attendanceList"/> 

另請注意,您正在以兩種不同的形式定義a4j:pollrich:dataTable,並且您沒有在表單中指定prependId="false"。但是,您正在引用不含表單ID的dataTable(位於reRender)。
基於OP評論的編輯。這裏是你如何應對前面加上ID,你有兩種可能的方式:

  1. 只需添加prependId="false"到您的形式
  2. 不要添加prependId="false"但定義形式的ID,並在reRender使用這些編號部分,這樣的事情:reRender="theIDYouGaveToYourForm:theIdOfYourDataTable"
+0

我切換到JavaScript,因爲某種刷新實際上發生。現在整個頁面正在刷新...... – mangusbrother

+1

當然,因爲你正在使用'h:commandLink'和'action'。我認爲使用'actionListener'會解決它(我不確定)。不過,我會建議使用'a4j:poll',因爲它有很多很好的功能 –

+0

我試着用你給我的a4j:poll。我可以說每隔5秒就會調用一次backing bean方法,就像我設置它一樣。但是表格沒有更新。 – mangusbrother

相關問題