本文整理匯總了Java中javax.faces.event.PreRenderViewEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PreRenderViewEvent類的具體用法?Java PreRenderViewEvent怎麽用?Java PreRenderViewEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PreRenderViewEvent類屬於javax.faces.event包,在下文中一共展示了PreRenderViewEvent類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processEvent
import javax.faces.event.PreRenderViewEvent; //導入依賴的package包/類
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreRenderViewEvent) {
UIViewRoot viewRoot = getUIViewRoot(event);
if (null != viewRoot && StringUtils.isNotEmpty(viewRoot.getViewId())) {
ExtendedActionListener listener
= createActionEventListener(event, PROP_PRERENDER_PREFIX);
if (null == listener) {
listener = createActionEventListener(PRERENDER_DEFAULT_KEY);
}
if (null != listener) {
ActionEvent ae = new ActionEvent(viewRoot);
listener.processAction(ae);
// 畫麵表示キー値、メッセージの設定
//merActionListener.setViewMessage();
String pageIdParameter = getPageIdParameter();
if (StringUtils.isNotEmpty(pageIdParameter)) {
// 畫麵リダイレクト処理前のエラーメッセージ設定
listener.addViewMessage(pageIdParameter);
FacesContext fc = FacesContext.getCurrentInstance();
Flash f = fc.getExternalContext().getFlash();
f.clear();
}
listener.setViewMessage();
} else {
// デフォルトPreRenderも存在しない場合は処理エラーとする.
throw new AbortProcessingException(
String.format("Can't create PreRenderViewListener. for viewId=[%s]",
getViewId(event)));
}
}
}
}
示例2: init
import javax.faces.event.PreRenderViewEvent; //導入依賴的package包/類
public void init(PreRenderViewEvent e) {
LOG.log(Level.INFO, "fire PreRenderViewEvent:" + e);
}
示例3: handleNonAjaxException
import javax.faces.event.PreRenderViewEvent; //導入依賴的package包/類
private void handleNonAjaxException(FacesContext context) {
Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator();
if (unhandledExceptionQueuedEvents.hasNext()) {
Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException();
if (exception instanceof AbortProcessingException) {
return; // Let JSF handle it itself.
}
// go up the exception chain to the cause
while ((exception instanceof FacesException || exception instanceof ELException )
&& exception.getCause() != null) {
exception = exception.getCause();
}
unhandledExceptionQueuedEvents.remove();
// put information about the exception in the log. For unhandled exceptions
// this should not already have been done.
LogUtils.logException(logger, exception.getMessage(), exception);
String viewName;
if (exception instanceof ViewExpiredException) {
viewName = "/error-pages/view-expired.xhtml";
} else if (exception instanceof EditorException ) {
viewName = "/error-pages/editor-error.xhtml";
} else {
viewName = "/error-pages/server-error.xhtml";
}
ExternalContext externalContext = context.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
requestMap.put("exception", exception);
FacesContext facesContext = FacesContext.getCurrentInstance();
try {
ViewHandler viewHandler = context.getApplication().getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(context, viewName);
context.setViewRoot(viewRoot);
context.getPartialViewContext().setRenderAll(true);
ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewName);
vdl.buildView(context, viewRoot);
context.getApplication().publishEvent(context, PreRenderViewEvent.class, viewRoot);
vdl.renderView(context, viewRoot);
context.responseComplete();
} catch (IOException e) {
LogUtils.logException(logger, "Failed to handled exception in non ajax request.", e);
}
facesContext.responseComplete();
}
while (unhandledExceptionQueuedEvents.hasNext()) {
// Any remaining unhandled exceptions are not interesting. First fix
// the first.
unhandledExceptionQueuedEvents.next();
unhandledExceptionQueuedEvents.remove();
}
}