<ui:repeat>中的<h:form>不能完全正常工作,只处理最后一个<h:form>

Raj*_*ajV 3 forms jsf-2 uirepeat

我想在同一页面中编辑项目列表.应使用单独的表单编辑每个项目.我正在创建啊:ui中的表单:重复.仅在提交最后一个表单时,用户输入才会应用于托管bean.对于所有其他表单,用户输入不会应用于模型.

@ManagedBean
public class Controller {
    Logger logger = Logger.getLogger("TestWeb");
    private List<Customer> customerList;

    public List<Customer> getCustomerList() {
        if (customerList == null) {
            customerList = new ArrayList<Customer>();
            customerList.add(new Customer("Daffy Duck", "daffy@example.com"));                          
            customerList.add(new Customer("Bugs Bunny", "bugs@example.com"));       
            customerList.add(new Customer("Samity Sam", "sam@example.com"));
        }
        return customerList;
    }
    public String updateCustomer(Customer c) {
        logger.info("Updating: " + c.getName());
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

在视图中,我有

<ui:repeat var="c" value="#{controller.customerList}">
<h:form>
  <h3>Edit Customer</h3>
  Name: <h:inputText value="#{c.name}"/><br/>
  E-mail: <h:inputText value="#{c.email}"/><br/>
  <h:commandButton value="Update"
    action="#{controller.updateCustomer(c)}"/>
</h:form>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)

我没有任何解决方案搜索了几个小时 这样做的正确方法是什么?我可以通过使用单个表单并在其中使用ui:repeat来破解它.但是有很多问题,我宁愿不采取这种方式.谢谢.

Bal*_*usC 9

这是<ui:repeat>Mojarra 国家拯救的一个错误.在http://java.net/jira/browse/JAVASERVERFACES上有几个类似的问题报告,其中包括问题2243.

你已经基本上2种选择:使用另一种迭代组件(例如<c:forEach>,<h:dataTable>,<t:dataList>,<p:dataList>,等),或者通过MyFaces的(替换钻嘴鱼科<ui:repeat>在这个结构正常工作在那里).