我有从支持 bean ArrayList 填充的 jsf 数据表。现在我需要将值与表的一列中的值进行比较,我该怎么做?
我的数据表:
<t:dataTable var="tabl"
rowIndexVar="rownum"
id="data"
value="#{bean.sortedList}"
>
.......... 我要比较数据的列:
<t:column>
<f:facet name="header">
<h:commandLink>
<h:outputText value="sortedList"/>
</h:commandLink>
</f:facet>
<f:verbatim> </f:verbatim>
<h:inputText value="#{tabl.numbers}"
id="numbers">
</h:inputText>
</t:column>
我的表结构:
<tbody id="myForm:data:tbody_element">
<tr>
...
<td> <input id="myForm:data:0:workAreaNumberU" name="myForm:data:0:workAreaNumberU" type="text" value="0001" size="4" onkeyup="value_altered(0);"></td>
</tr>
....
<tr>
...
<td> <span id="_idJsp1:data:1:workAreaNumber">0104</span></td>
...
</tr>
</tbody>
终于这样解决了(基于我的表结构)
var table = document.getElementById("myForm:data:tbody_element");
var new_wa;
for (var i = 0, row; row = table.rows[i]; i++) {
var new_wa_box = document.getElementById("myForm:data:" + i + ":workAreaNumberU");
if( new_wa_box != null ) {
new_wa = new_wa_box.value;
}else{
new_wa_box = document.getElementById("myForm:data:" + i + ":workAreaNumber");
new_wa = new_wa_box.innerHTML;
}
alert("row new_wa_box = "+new_wa);
}