I have a datatable, and have links that allow the user to insert a row directly below the current row. This should then update the numbering.
It works perfectly once, creating a new row, populating the number and adding one to the numbering for all rows below.
If I click anything else though, it seems as though the ajax request completes but nothing happens.
You will see that I am using the #{table} variable to get the row index of the UIData element. I have tried using process="@form" and process="@this" in the commandLink, but to no avail sadly. Likewise, my method was returning void so I set it to return a null String, but the same result occurred.
XHTML
<h:form id="feForm">
<p:dataTable value="#{fichaExpandidaBean.feFlujoNormalList}" binding="#{table}" var="fn">
<p:column headerText="Paso:">
<h:outputText value="#{fn.orden}-"/>
</p:column>
<p:column headerText="Descripcion:">
<h:inputText value="#{fn.descripcion}" style="width:98%;"/>
</p:column>
<p:column headerText="Acciones">
<p:commandLink style="margin: 5px;" action="#{fichaExpandidaBean.agregarFilaFlujoNormal(table.rowIndex)}" update="@form">
<h:graphicImage title="Agregar fila abajo." value="/resources/imagenes/agregarFila.png" alt="AgregarFila"/>
</p:commandLink>
</p:column>
</p:dataTable>
</h:form>
Bean:
@Named(value = "fichaExpandidaBean")
@ConversationScoped
public class FichaExpandidaBean implements Serializable {
@Inject
private Conversation conversation;
...etc...
public String agregarFilaFlujoNormal(int row){
FeFlujonormal fn = new FeFlujonormal();
fn.setOrden(row + 2);
feFlujoNormalList.add(row + 1, fn);
for(int i = row + 2; i < feFlujoNormalList.size(); i++){
FeFlujonormal feTemp = feFlujoNormalList.get(i);
feTemp.setOrden(feTemp.getOrden()+1);
}
return null;
}
EDIT: I don't think it's a Primefaces issue, I get the same result with the following code:
<h:dataTable value="#{fichaExpandidaBean.feFlujoNormalList}" binding="#{table}" var="fn">
<h:column>
<f:facet name="header">Paso</f:facet>
<h:outputText value="#{fn.orden}-"/>
</h:column>
<h:column>
<f:facet name="header">Descripcion</f:facet>
<h:inputText value="#{fn.descripcion}" style="width:98%;"/>
</h:column>
<h:column>
<f:facet name="header">Acciones</f:facet>
<h:commandLink style="margin: 5px;" action="#{fichaExpandidaBean.agregarFilaFlujoNormal(table.rowIndex)}">
<f:ajax render="@form"/>
<h:graphicImage title="Agregar fila abajo." value="/resources/imagenes/agregarFila.png" alt="AgregarFila"/>
</h:commandLink>
</h:column>
</h:dataTable>