我想将 ah:commandLink 放入 ah:dataTable 以删除单行。在这里,我有一个不起作用的代码,希望您能帮助我。这段代码甚至没有调用我的删除方法。h:dataTable 的数据来自数据库。
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>
第一个BackingBean
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class FirstBackingBean {
public void delete() {
System.out.println("\nBUTTON CLICKED\n");
}
}
第二个BackingBean
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class SecondBackingBean {
// ...
}