[英]get row from rich:datatable binding table
I am using java 6 jsf 1.2 and richfaces 3.3.3 When I call the function getRowData on the Binded UIDataTable 我正在使用java 6 jsf 1.2和richfaces 3.3.3在绑定UIDataTable上调用getRowData函数时
public void priorityChanged(ValueChangeEvent event) {
Task currentTask = (Task) table.getRowData();
with 同
<h:selectOneMenu id="id182_#{rkv}" value="#{dataItem.priority}"
valueChangeListener="#{customerAdminHandler.priorityChanged}"
onchange="submit()">
<f:selectItems value="#{customerAdminHandler.priorityTypes}" />
</h:selectOneMenu>
i get an exception on the table.getRowData(); 我在table.getRowData()上遇到异常;
java.lang.IllegalArgumentException
at javax.faces.model.ListDataModel.getRowData(ListDataModel.java:150)
at org.ajax4jsf.model.SequenceDataModel.getRowData(SequenceDataModel.java:147)
at org.ajax4jsf.component.UIDataAdaptorBase.getRowData(UIDataAdaptorBase.java:257)
I bypassed the problem by using 我通过使用绕过了这个问题
<f:setPropertyActionListener value="#{dataItem}"
target="#{customerProductsHandler.currentApp}" />
instead of a binding table. 而不是绑定表。 the same code worked for me on a clean environment so i guess there is some sort of jar problem.
相同的代码在干净的环境下对我有用,所以我猜可能存在某种jar问题。
anyway , for future reference I found the following information usefull for using a binding table 无论如何,为了以后的参考,我发现以下信息对于使用绑定表很有用
Richfaces 3.3 uses:
org.richfaces.component.html.HtmlDataTable
Richfaces 4 uses:
org.richfaces.component.UIDataTable
jsf1.2 uses:
javax.faces.component.html.HtmlDataTable;
jsf 2 uses:
import javax.faces.model.DataModel;
Have you binded your rich:dataTable
to a component attribute of your managed bean? 您是否已将
rich:dataTable
绑定到托管bean的component属性? Plus, the type of the attribute must be org.richfaces.component.html.HtmlDataTable
, at least this is how we achieved to select one row of the datatable (using the example code of @BalusC here ). 此外,该属性的类型必须是
org.richfaces.component.html.HtmlDataTable
,至少这是我们如何实现的选择DataTable的一个行(使用@BalusC的示例代码在这里 )。
The jsp code: jsp代码:
<script type="text/javascript">
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if(el[i].name != undefined) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
}
radio.checked = true;
}
</script>
<!-- some html/jsp code -->
<rich:dataTable id="dtDocCartera" style="width:100%"
binding="#{busquedaDocCartera.hdtCredito}"
value="#{busquedaDocCartera.lstCredito}" var="credito" rows="15">
<rich:column>
<f:facet name="header">
<h:outputText value="Select" />
</f:facet>
<h:selectOneRadio onclick="dataTableSelectOneRadio(this)"
valueChangeListener="#{busquedaDocCartera.setSelectedItem}">
<f:selectItem itemValue="null"/>
</h:selectOneRadio>
</rich:column>
<rich:column style="text-align:center">
<f:facet name="header">
<h:outputText value="Some Data" />
</f:facet>
<h:outputText value="#{credito.data}" />
</rich:column>
</rich:dataTable>
And this is our managed bean: 这是我们的托管bean:
@KeepAlive(ajaxOnly=false)
public class PBusquedaDocCartera {
private HtmlDataTable hdtCredito;
private List<ECredito> lstCredito;
//This will be the selected data
private ECredito credito;
//getters and setters for attributes...
public void setSelectedItem(ValueChangeEvent event) {
try {
credito = (ECredito)hdtCredito.getRowData();
} catch (Exception objEx) {
//logging errors...
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.