I want to know if someone of you have any idea or solution about problem concerning how to show detail or delete an object presenting in a dataTable ?
I display data from database using MySql in jsf as a dataTable with c开发者_如何学运维olumns containing commandLink for show detail and commandButton for deleting this object , all objects are contained in a Arraylist.
<h:dataTable id="dt1" value="#{MyBean.myList}" var="item" >
<f:facet name="header">
<h:outputText value="This is 'dataTable' demo" />
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="name"/>
</f:facet>
<h:outputText value="#{item.name}"></h:outputText>
</h:column>
...
in your button code :
<h:column><h:commandButton value="delete" action="#{MyBean.delete}" /></h:column>
Your backing-bean :
private DataModel<Item> myList = new ListDataModel<Item>(items);
public void delete() {
items.remove(myList.getRowData());
}
精彩评论