2
我想使用Omnifaces實現ViewScoped CDI bean。使用jsf頁面中的ajax調用用於填充primefaces數據表的搜索結果列表的Bean方法。如果將bean作用域設置爲會話,則一切正常。當我嘗試將範圍設置爲Omnifaces ViewScope時,容器開始無數次地反覆創建和銷燬bean。這裏是bean代碼:Omnifaces viewcoped bean被重新創建
...
import javax.inject.Named;
import org.omnifaces.cdi.ViewScoped;
@Named
@ViewScoped
public class FindClientBean implements Serializable {
@Inject
private ClientDAO clientDAO;
@NotNull(message="Search string cannot be empty")
private String searchString;
private List<Client> resultList;
@PostConstruct
public void init() {
System.out.println("init");
}
@PreDestroy
public void end() {
System.out.println("end");
}
public void findClient() {
System.out.println("method");
resultList = clientDAO.findClientByNameOrLastnamePart(searchString);
}
//Getters and setters..
}
樣本輸出(有更多inits和一個方法調用結束,我跳過它們):
01:51:50,044 INFO [stdout] (http-localhost-127.0.0.1-9090-5) init
01:51:50,044 INFO [stdout] (http-localhost-127.0.0.1-9090-4) init
01:51:50,044 INFO [stdout] (http-localhost-127.0.0.1-9090-5) end
01:51:50,045 INFO [stdout] (http-localhost-127.0.0.1-9090-4) end
01:51:50,045 INFO [stdout] (http-localhost-127.0.0.1-9090-5) init
01:51:50,045 INFO [stdout] (http-localhost-127.0.0.1-9090-4) init
01:51:50,046 INFO [stdout] (http-localhost-127.0.0.1-9090-5) end
01:51:50,046 INFO [stdout] (http-localhost-127.0.0.1-9090-4) method
01:51:50,047 INFO [stdout] (http-localhost-127.0.0.1-9090-5) init
01:51:50,047 INFO [stdout] (http-localhost-127.0.0.1-9090-5) end
01:51:50,048 INFO [stdout] (http-localhost-127.0.0.1-9090-5) init
01:51:50,048 INFO [stdout] (http-localhost-127.0.0.1-9090-5) end
01:51:50,049 INFO [stdout] (http-localhost-127.0.0.1-9090-5) init
01:51:50,049 INFO [stdout] (http-localhost-127.0.0.1-9090-5) end
什麼可以嗎?沒有找到相關問題。 我的配置:JBoss AS 7.1,Omnifaces 1.6.3,Primefaces 4.0
你在做客戶端操作? –
究竟哪個AS 7.1顛覆? 7.1.0?因此,與Mojarra 2.1.5?而且,當您使用'javax.faces.bean'包中的'@ManagedBean @ ViewScoped'時,問題是否消失? – BalusC
Alexandre:我試圖通過數據庫的ajax請求使用搜索字符串填充primefaces數據表。 – Cass