开发者

How to force refresh of datatable via AJAX in JSF 2.0?

I've got datatable, wh开发者_运维技巧ich is pulling information from a database. I've added a button to the form that I want to use to force the table (id of "table") to refresh, however I'm not sure how to do it. What I have now is:

<h:commandButton value="Refresh">
    <f:ajax render="table"/>
</h:commandButton>

My goal was to have the table component be forced to render when the button is clicked. However, it appears that either the click is being ignored, or it's returning cached data, rather than actually going out and calling my database code again.

What am I doing wrong?


You have to specify an action in your commandButton which calls a bean and refreshes the data displayed in the table (currently the button does nothing). I'm not a Pro, but i think it should look like this:

<h:commandButton value="Refresh" action="#{myBean.refreshData}">
  <f:ajax render="table"/>
</h:commandButton>


Ugh. It's actually working, just incredibly painfully slow. We switched database servers recently, and a query that took less than a second on the old one just happens to take 20+ seconds on the new one. I was just timing out while watching it. Sigh.

As a side note, as soon as I figured that out, I tested both with and without an action. Works both ways (with the getter doing the lookup).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜