我正在使用primefaces 5.0在wildfly 8.2.0上(mojarra 2.2.8)。
我尝试使用一个简单的PrimeFaces DataTable具有扩展功能,但是每次我展开一行时,都会触发我的后退bean @PostConstruct
(重新加载数据,该数据首先将@ViewScoped
的使用无效)。
我在Stackoverflow上看到了有关此问题的其他问题,但是没有解决方案对我有用:
- 我正在使用JSF 2.2
- 我不使用任何JSTL标签
- 我禁用Web.xml中的部分状态
- 我尝试使用不同的
@ViewScoped
(bean,view甚至omlnifaces'One)
我的bean:
@Named
@javax.faces.view.ViewScoped
@SuppressWarnings("serial")
public class TestBean implements Serializable {
private List<String> things;
@PostConstruct
public void initialize() {
System.out.println("initializing...");
this.things = Arrays.asList("michael", "david", "paul");
}
public List<String> getThings() {
return this.things;
}
}
我的模板:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Test</title>
</h:head>
<h:body>
<p:dataTable value="#{testBean.things}" var="thing">
<p:column>
<p:rowToggler />
</p:column>
<p:column>
<h:outputText value="#{thing}" />
</p:column>
<p:rowExpansion>
<h:outputText value="#{thing}" />
</p:rowExpansion>
</p:dataTable>
</h:body>
</html>
要工作, <p:dataTable>
必须在 <h:form>
中。