datatable - JSF 2.0 Dynamically Remove Components -
as follow on answered question on adding components dynamically in jsf 2.0 (see link below), approach of using datatable, removing 1 of added components?
based on code snippet in other question linked, need following changes:
add column delete button table.
<h:column><h:commandbutton value="delete" action="#{bean.delete}" /></h:column>
add
datamodel<item>
property bean , wrap list of items in able obtain table row button clicked.private datamodel<item> model = new listdatamodel<item>(items);
(don't forget getter, note can instantiate in bean constructor or postconstruct)
use in datatable instead.
<h:datatable value="#{bean.model}" var="item">
add delete method bean.
public void delete() { items.remove(model.getrowdata()); }
see also:
- benefits , pitfalls of
@viewscoped
- contains jsf 2.0 crud table example
Comments
Post a Comment