Java 从rich:datatable绑定表获取行
我正在使用Java6JSF1.2和RichFaces3.3.3 在绑定的UIDataTable上调用函数getRowData时Java 从rich:datatable绑定表获取行,java,jsf,datatable,richfaces,Java,Jsf,Datatable,Richfaces,我正在使用Java6JSF1.2和RichFaces3.3.3 在绑定的UIDataTable上调用函数getRowData时 public void priorityChanged(ValueChangeEvent event) { Task currentTask = (Task) table.getRowData(); 与 您是否已将rich:dataTable绑定到托管bean的组件属性?另外,属性的类型必须是org.richfaces.component.html.H
public void priorityChanged(ValueChangeEvent event) {
Task currentTask = (Task) table.getRowData();
与
您是否已将
rich:dataTable
绑定到托管bean的组件属性?另外,属性的类型必须是org.richfaces.component.html.HtmlDataTable,至少这是我们选择datatable的一行的方法(使用@BalusC示例代码)
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>
功能数据表选择器收音机(收音机){
var id=radio.name.substring(radio.name.lastIndexOf(“:”);
var el=radio.form.elements;
对于(变量i=0;i
这是我们的托管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...
}
}
}
@KeepAlive(ajaxOnly=false)
公共类PBUSQUEDADOCATERA{
私有HtmlDataTable hdtCredito;
私人名单;
//这将是选定的数据
私人埃雷迪托·克雷迪托;
//属性的getter和setter。。。
public void setSelectedItem(ValueChangeEvent事件){
试一试{
credito=(ECredito)hdtCredito.getRowData();
}捕获(异常对象){
//日志记录错误。。。
}
}
}
我使用
<f:setPropertyActionListener value="#{dataItem}"
target="#{customerProductsHandler.currentApp}" />
在数据表中,对吗?它到底是哪个数据表组件?
,对吗?是的,它是一个rich:dataTable,我的表是一个UIDataTable;我敢打赌一定是RichFaces那边的虫子。它与
配合使用应该很好。尝试将值更改事件排队到调用应用程序
。
@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...
}
}
}
<f:setPropertyActionListener value="#{dataItem}"
target="#{customerProductsHandler.currentApp}" />
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;