【发布时间】:2017-02-10 07:07:58
【问题描述】:
目前我有这段代码,它通过 html 请求动态添加组件。它按我的预期工作。但我想通过使用 ajax 请求而不是 html 添加组件。
test.xhtml
<h:dataTable value="#{testController.items}" var="item">
<h:column><h:inputText value="#{item.name}" /></h:column>
<h:column><h:commandButton value="remove" action="#{testController.remove(item)}" /></h:column>
</h:dataTable>
<h:commandButton value="add" action="#{testController.add}" />
支持豆
@ManagedBean
@ViewScoped
public class TestController implements Serializable {
private List<Language> items = new ArrayList<Language>();
public void add() {
items.add(new Language());
}
public void remove(Language item) {
items.remove(item);
}
public List<Language> getItems() {
return items;
}
}
现在我需要使用 ajax 请求来执行此操作。我该怎么做?
【问题讨论】: