Obtener datos de una Tabla desde un Bean


< h:dataTable var="item" value="#{MyBean.items}"
binding="#{MyBean.dataTable}" >
< h:column>
< h:outputText styleClass="output" value="#{item.productName}"/>
< /h:column>

< h:column>
< h:commandButton value="remove" action="#{MyBean.remove}" />
< /h:column>
< /h:dataTable>






En el bean solo tenemos que...


public class MyBean {
private ArrayList items = new ArrayList();
private HtmlDataTable dataTable;

public ArrayList getItems() {
return items;
}

public void setItems(List items) {
this.items = new ArrayList(items);
}

public void remove(){
ItemBean item = (ItemBean) getDataTable().getRowData();
items.remove(item);
}

public HtmlDataTable getDataTable() {
return dataTable;
}

public void setDataTable(HtmlDataTable dataTable){
this.dataTable = dataTable;
}

}



By Miguel Ruiz on miércoles, 19 de enero de 2011 | | A comment?
0 responses to “Obtener datos de una Tabla desde un Bean”

Leave a Reply