0
votes

I have a rich:dataTable with dataScroller. In each page I need to show 5 records. Record count dynamically changes. I refresh dataTable every 20 seconds to see if there is any new record.

If there are more than 5 records, dataTable will have two or pages.

If there are more than one pages for dataTable, is it possible to say dataScroller to switch pages every 10 seconds? After it shows last page then it should back to first page.

Thanks

3

3 Answers

0
votes

Well, you can bind dataScroller with the bean (using de prop. "binding") and use a javascript to "click a invisible button" that executes a bean function to go to the next page..

Xhtml:

<script type="text/javascript">
   var t;
   t=setTimeout("timedCount()", 1000); 

   function timedCount() {
      document.getElementById('formName:button').click();

      t=setTimeout("timedCount()", 10000); 
   }
</script>

(...)

<h:commandButton id="button" action="#{bean.scrollNext}" reRender="tableID"
                 style="visibility:hidden;"/>

(...)

Bean:

HtmlDataScroller scroll; //(im not sure about the "HtmlDataScroller")

(...)

public void scrollNext() { scroll.next(); }

(...)

//Gets and sets to bind the scroller
get; set;...

Dont forget to make a new instance of htmlDataScroller or you'll get a nullPointException..

0
votes

I guess this is not impossible. Please try to have a look into a4j:poll component. Will try and hopefully post more updates

0
votes

AFAIK, this is not possible with default richfaces. I think you will be able to refresh the data in your table periodically using <a4j:poll>, but not the automatic page-switching. However, the <rich:datascroller> has a client-side API (which is described here). Combining this with javascript timing may be the way to get the page-switching working.