Question

In my page i have a rich:datatable which obtains the data from a backing bean. I would like to call a method in the bean to refresh the data and after refresh the table.

I currently have the following situation, but the the method is being called but the table remains un refreshed

<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)">
Was it helpful?

Solution

Usually, I define the action to be called in the a4j:poll itself:

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

Also please notice that you are defining a4j:poll and rich:dataTable in two separate forms and that you are not specifying prependId="false" in your forms. However you are referencing to the dataTable (in reRender) without the form ID.
EDIT based on OP comments. Here is how you deal with the prepend id, you have two possible ways:

  1. Just add prependId="false" to your forms
  2. Don't add a prependId="false" but define your forms IDs, and use these ids in the reRender part, something like this: reRender="theIDYouGaveToYourForm:theIdOfYourDataTable"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top