如何仅更新jsf datatable列 [英] How do update jsf datatable column only
问题描述
< 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屋!