2012-06-26 23 views

回答

1

所依賴的你的需要,例如,如果你想在你的bean initliaze東西,你可以使用f:eventpreRenderView

檢查此鏈接: http://www.mkyong.com/jsf2/jsf-2-prerenderviewevent-example/

但是你應該知道該事件是每個請求調用:ajax,驗證失敗....您可以檢查是否它的新請求是這樣的:

public boolean isNewRequest() { 
     final FacesContext fc = FacesContext.getCurrentInstance(); 
     final boolean getMethod = ((HttpServletRequest) fc.getExternalContext().getRequest()).getMethod().equals("GET"); 
     final boolean ajaxRequest = fc.getPartialViewContext().isAjaxRequest(); 
     final boolean validationFailed = fc.isValidationFailed(); 
     return getMethod && !ajaxRequest && !validationFailed; 
    } 
+0

謝謝。這是我需要的。 – webmeiker

相關問題