开发者

How to delete or show details about an Object contained in list and presented in dataTable using JSF framework?

开发者 https://www.devze.com 2023-03-09 23:28 出处:网络
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 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());
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消