【发布时间】:2012-10-29 14:35:14
【问题描述】:
表格和表格在同一页面上。当用户添加表单详细信息并单击添加时,应将数据复制到表中。
当用户第二次输入详细信息并单击添加时(表中已经存在数据),第一个值被新值覆盖,列表中的下一个为空。
我们如何在表格上显示这两个值。
名称.xhtml
<h:form>
<h:inputText value="#{bean.fName}"/>
<h:inputText value="#{bean.lName}"/>
<h:dataTable value="#{bean.list}" var="name">
<h:column>
<h:outputText value="#{name.fName}">
</h:column>
</h:dataTable>
<h:commandLink action="#{bean.add}"/>
</h:form>
Bean.java //Bean类是ViewScoped
@ManagedProperty(value="#{buyerTO}") 受保护的买家对买家TO;
列出买家TOList = new ArrayList(); // BuyerTO 在 ViewScope 中
public String addBuyer(){
buyerTOList.add(buyerTO);
buyerTO = new BuyerTO();
return "";
}
【问题讨论】: