如何仅更新jsf datatable列 [英] How do update jsf datatable column only

查看:196
本文介绍了如何仅更新jsf datatable列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据表的一列中有一个计数器。一旦计数器达到一定的时间,我需要更改该列的背景颜色。表的数据正在从数据库中提取。我使用a4j:poll来重新列出列,但问题是整个表被渲染。以下代码如下:

 < a4j:region> 
< h:form>
< a4j:poll id =pollinterval =1000enabled =truereRender =blinklimitToList =true/>
< / h:form>
< / a4j:region>

< h:form id =form1>
< a4j:outputPanel id =panel1ajaxRendered =true>
< h:dataTable id =blinksstyleClass =tableClassvalue =#{bean.list}var =_ item>
< h:column id =blink>
< f:facet name =header>
< h:outputText value =Header1/>
< / f:facet>
< div id =div1class =#{bean.check()?'red':''}>
< h:outputText value =计数器文本(计数秒)/>
< / h:column>
< / h:dataTable>
< / a4j:outputPanel>
< / h:form>


解决方案

如果您符合以下最低要求JSF 2.0,EL 2.1和Servlet 2.5



您可以尝试 Omnifaces的Ajax#updateColumn(),有一个如何在展示中使用它的例子


请注意,Ajax#updateRow()和Ajax#updateColumn()只能在
a固定ID包装在某些容器组件中时更新
单元格内容。



I have a counter in a column of a datatable. Once the counter reaches a certain time, I need to change the background color of that column only. The data for the table is being pulled from a database. I'm using a4j:poll to reRender the column but the issue is that the entire table is rendered. Some code below:

    <a4j:region>
        <h:form>
            <a4j:poll id="poll" interval="1000" enabled="true" reRender="blink" limitToList="true" />
        </h:form>
    </a4j:region>

<h:form id="form1">         
    <a4j:outputPanel id="panel1" ajaxRendered="true">               
    <h:dataTable id="blinks" styleClass="tableClass" value="#{bean.list}" var="_item">
<h:column id="blink">
  <f:facet name="header">
    <h:outputText value="Header1" />
  </f:facet>
    <div id="div1" class="#{bean.check() ? 'red' :''}">
            <h:outputText value="Counter text (counts seconds)" />
</h:column>
</h:dataTable>
</a4j:outputPanel>
</h:form>

解决方案

If you meet the following minimum req' JSF 2.0, EL 2.1 and Servlet 2.5

You can try out the Ajax#updateColumn() by Omnifaces , there is an example on how to use it in the showcase

Note that Ajax#updateRow() and Ajax#updateColumn() can only update cell content when it has been wrapped in some container component with a fixed ID.

这篇关于如何仅更新jsf datatable列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆