我有一個頁面通過querystring接收一個id號碼並顯示相關文章。JSF 2.0查詢字符串傳播
我用<f:viewParams>
與preRenderView事件和數據從數據庫中@PostConstruct方法加載:
@Named
@RequestScoped
public class Bean {
private Long id;
@PostCostruct
public void init() {
if (this.id != null) {
// load data from db
}
}
public String modify() {
// update data
}
}
當我調用數據被正確加載頁面,但是當我點擊修改按鈕
<h:commandButton value="Modify" action="#{bean.modify}" />
我得到一個錯誤,因爲沒有查詢字符串參數發送到bean,從而沒有數據加載。
如何傳播查詢字符串參數?
但我需要在方法返回之前id參數,甚至在調用該方法,在init方法了。 – Alf 2011-01-29 21:33:19