【发布时间】:2014-04-30 16:55:27
【问题描述】:
如何为 JSF dataTable 中的每一行检索 inputText 值,因为该数据不是我们在循环中迭代的对象中的属性。
(此处为 0 作为默认值)。我无法更改 Class 属性(此处为 Product)
<h:form>
<p:dataTable var="product" value="#{bean.products}">
<p:column headerText="Id">
<h:outputText value="#{product.id}" />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{product.name}" />
</p:column>
<p:column headerText="Quantity">
<h:inputText size="3" value="0" />
</p:column>
</p:dataTable>
<h:commandButton value="Submit" action="#{bean.submit}"/>
</h:form>
Bean.class
@ManagedBean
...
public void submit() {
List<Product> products = this.getProducts();
for(Product product : list) {
System.out.println("Product.name : "+ Product.name );
System.out.println("Quantity : "+ ?? );
}
}
【问题讨论】:
标签: jsf jsf-2 datatable attributes