当前位置: 首页>>代码示例>>Java>>正文


Java PreRenderViewEvent类代码示例

本文整理汇总了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)));
            }
        }
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:34,代码来源:PreRenderViewListener.java

示例2: init

import javax.faces.event.PreRenderViewEvent; //导入依赖的package包/类
public void init(PreRenderViewEvent e) {
    LOG.log(Level.INFO, "fire PreRenderViewEvent:" + e);
}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:4,代码来源:PostRenderViewBean.java

示例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();
        }

    }
 
开发者ID:metno,项目名称:metadata-editor,代码行数:62,代码来源:EditorExceptionHandler.java


注:本文中的javax.faces.event.PreRenderViewEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。