我遇到一個問題,使用Primefaces dataTable,這是jsf將調用我的託管bean init()這將做一個數據庫搜索。JSF PrimeFaces ViewScope不調用init()
在我的jsf中,用戶可以執行另一個搜索,在String中傳遞參數。
<p:commandButton id="btnChild" type="Submit" icon="ui-icon-plus" styleClass="action-buttons" value="Child" update=":frmSysMenu:messages dtSysMenu" ajax="false" action="#{Controller.doParent('C')}" process="dtSysMenu" />
我管理的Bean能夠執行doParent(字符串),並會再次返回到搜索屏幕,但一旦我的屏幕加載時,它會調用的init()其中:
@PostConstruct
@Override
public void init(){
try {
doSearch(nodeValue,"root");
setParentNode(nodeValue);
} catch (Exception e) {
addErrorMessage(e.getMessage());
e.printStackTrace();
Messages.addGlobalError(e.getMessage());
LOG.error(e.toString(), e);
}
}
它會回到第一個查詢。 有沒有其他方法可以做?
RequestScoped有幫助嗎?
歡迎來到Stackoverflow!如果你已經解決了你的問題(恭喜),那麼請張貼它作爲答案。它可以幫助其他人快速找出問題已經解決。 – mabi
非常感謝!對不起,我是新的,並感謝您的建議:D –
可能重複[JSF 2.1查看範圍管理bean重新創建每個刷新](http://stackoverflow.com/questions/19153374/jsf-2-1-view-範圍的管理,豆重新創建上,每刷新) – Kukeltje