本文整理匯總了Java中javax.faces.context.FacesContext.getCurrentPhaseId方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext.getCurrentPhaseId方法的具體用法?Java FacesContext.getCurrentPhaseId怎麽用?Java FacesContext.getCurrentPhaseId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.context.FacesContext
的用法示例。
在下文中一共展示了FacesContext.getCurrentPhaseId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: goToErrorPage
import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
* @param context
* @param e
* @throws Throwable
*/
private void goToErrorPage(FacesContext context, Throwable e) {
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
request.setAttribute(ERROR_EXCEPTION + "_stacktrace", e);
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
throw new FacesException(e);
}
if (e instanceof FileNotFoundException) {
logger.log(Level.WARNING,"File not found", e);
throw new FacesException(e);
}
request.setAttribute(ERROR_EXCEPTION_TYPE, e.getClass().getName());
request.setAttribute(ERROR_MESSAGE, e.getMessage());
request.setAttribute(ERROR_REQUEST_URI, request.getHeader("Referer"));
request.setAttribute(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
String errorPage = findErrorPage(e);
if (!has(errorPage)) {
String errorPageParam = context.getExternalContext().getInitParameter(Constants.InitialParams.ERROR_PAGE);
if (!has(errorPageParam)) {
errorPage = Constants.DEFAULT_ERROR_PAGE;
}
}
context.getApplication().getNavigationHandler().handleNavigation(context, null, errorPage);
context.renderResponse();
}
示例2: handleBusinessException
import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
* @param context
* @param e application business exception
*/
private void handleBusinessException(FacesContext context, BusinessException e) {
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
throw new FacesException(e);
}
if (has(e.getExceptionList())) {
for (BusinessException be : e.getExceptionList()) {
addFacesMessage(be);
}
} else { //Single exception
addFacesMessage(e);
}
validationFailed();
context.renderResponse();
}