本文整理汇总了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();
}