I'm using the Primefaces datatable component with the option to select a row.
I want to select a row and get it on the backingBean to process.
Here is the code for the table:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Table Test</title>
</h:head>
<h:body>
<h:form id="formulario">
<p:dataTable value="#{detail_MB.resultList}" var="dataItem"
id="tabla1" rowSelectListener="#{detail_MB.processDataItem}"
selectionMode="single">
<p:column headerText="Producto" style="width:100px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dataItem.lista[0][1]}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{dataItem.lista[0][1]}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Precio" style="width:150px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dataItem.lista[1]}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{dataItem.lista[1]}" style="width:100%">
<f:converter binding="#{detail_MB.floatC}" />
</h:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Cantidad" style="width:200px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dataItem.lista[2]}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{dataItem.lista[2]}" style="width:100%">
<f:converter binding="#{detail_MB.integerC}" />
</h:inputText>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
Code: Select all
public void processDataItem(SelectEvent ev){
// Get selected MyData item to be edited.
ObjGenerico dataItem = (ObjGenerico) ev.getObject();
System.out.println("Fila seleccionada: "+dataItem.getLista());
}
Why this behaviour happens? Is there a bug?
Somebody can help me?
I've read the Migration Guide to 3.0 (http://wiki.primefaces.org/display/Gene ... ide+to+3.0) but I don't know how to configure the rowSelectListener for the table with p:ajax.