欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JSF Binding属性

程序员文章站 2024-03-13 16:22:09
...
<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>

 

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;
	}
}

 当点击remove按钮时,那一行记录被删除

相关标签: JSF