I want to put a h:commandLink in a h:dataTable to delete a single row. Here I have a code which does not work and I hope you can help me. This code doesn't even call my delete method. The data for the h:dataTable comes from a database.
XHTML
<h:form>
<div class="center">
<h:dataTable id="list" value="#{firstBackingBean.list}"
var="first" styleClass="center">
<!-- other columns (take data from firstBackingBean) -->
<h:column>
<f:facet name="header" />
<h:commandLink value="delete" action="#{secondBackingBean.delete}" >
<f:ajax execute="@form" render="list" />
<f:param name="id" value="#{first.id}"/>
</h:commandLink>
</h:column>
</h:dataTable>
</div>
</h:form>
FirstBackingBean
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class FirstBackingBean {
public void delete() {
System.out.println("\nBUTTON CLICKED\n");
}
}
SecondBackingBean
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class SecondBackingBean {
// ...
}