Java 类javax.faces.context.Flash 实例源码

项目:Hotel-Reservation-Tool    文件:NewReservationBean.java   
protected String navigateToBookingsPage(Reservation realReservation) {
    Flash flash = getCurrentInstance().getExternalContext().getFlash();
    FacesMessage message = new FacesMessage(format("Room %s is booked for %s; Reservation number %s; Cost: %s EUR",
            booking.getRoom(), booking.getGuest(), realReservation.getReservationNumber(),
            realReservation.getCostsInEuro()));
    getCurrentInstance().addMessage(null, message);
    booking = null;
    flash.setKeepMessages(true); // only keep messages if we do not have a backlink
    return format("/booking.xhtml?reservationNumber=%s&faces-redirect=true", realReservation.getReservationNumber());
}
项目:linkbinder    文件:PreRenderViewListener.java   
@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)));
            }
        }
    }
}
项目:conta    文件:AbstractMBean.java   
protected Object flashGet(String key) {
    Flash flash = flash();

    if (flash.size() > 0) {
        Object result = flash.get(key);

        if (isRemovingFlash()) {
            flash.values().remove(result);
        }

        return result;
    }
    return null;
}
项目:linkbinder    文件:FacesContextMock.java   
@Override
public Flash getFlash() {
    return new FlashMock();
}
项目:conta    文件:AbstractMBean.java   
private Flash flash() {
    return FacesContext.getCurrentInstance().getExternalContext().getFlash();
}
项目:conta    文件:AbstractMBean.java   
protected void flashPut(String key, Object value) {
    Flash flash = flash();
    flash.put(key, value);
}
项目:GOG    文件:JSFUtils.java   
public static Flash getFlash() {
    return FacesContext.getCurrentInstance().getExternalContext().getFlash();
}
项目:Hotel-Reservation-Tool    文件:FacesMessageHelper.java   
public static void addFlashMessage(Severity severity, String summary) {
    Flash flash = getCurrentInstance().getExternalContext().getFlash();
    flash.setKeepMessages(true);
    FacesMessage message = new FacesMessage(severity, summary, summary);
    getCurrentInstance().addMessage(null, message);
}
项目:baseJSF    文件:FacesUtil.java   
public static Flash getFlash(){
    return getEC().getFlash();
}
项目:deltaspike    文件:DefaultErrorViewAwareExceptionHandlerWrapper.java   
@Override
public void handle() throws FacesException
{
    lazyInit();
    Iterator<ExceptionQueuedEvent> exceptionQueuedEventIterator = getUnhandledExceptionQueuedEvents().iterator();

    while (exceptionQueuedEventIterator.hasNext())
    {
        ExceptionQueuedEventContext exceptionQueuedEventContext =
                (ExceptionQueuedEventContext) exceptionQueuedEventIterator.next().getSource();

        @SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
        Throwable throwable = exceptionQueuedEventContext.getException();

        String viewId = null;

        if (!isExceptionToHandle(throwable))
        {
            continue;
        }

        FacesContext facesContext = exceptionQueuedEventContext.getContext();
        Flash flash = facesContext.getExternalContext().getFlash();

        if (throwable instanceof ViewExpiredException)
        {
            viewId = ((ViewExpiredException) throwable).getViewId();
        }
        else if (throwable instanceof ContextNotActiveException)
        {
            //the error page uses a cdi scope which isn't active as well
            //(it's recorded below - see flash.put(throwable.getClass().getName(), throwable);)
            if (flash.containsKey(ContextNotActiveException.class.getName()))
            {
                //TODO show it in case of project-stage development
                break;
            }

            if (facesContext.getViewRoot() != null)
            {
                viewId = facesContext.getViewRoot().getViewId();
            }
            else
            {
                viewId = BeanProvider.getContextualReference(ViewConfigResolver.class)
                        //has to return a value otherwise this handler wouldn't be active
                        .getDefaultErrorViewConfigDescriptor().getViewId();
            }
        }

        if (viewId != null)
        {
            UIViewRoot uiViewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);

            if (uiViewRoot == null)
            {
                continue;
            }

            if (facesContext.isProjectStage(javax.faces.application.ProjectStage.Development) ||
                    ProjectStageProducer.getInstance().getProjectStage() == ProjectStage.Development ||
                    ProjectStageProducer.getInstance().getProjectStage() instanceof TestStage)
            {
                throwable.printStackTrace();
            }

            facesContext.setViewRoot(uiViewRoot);
            exceptionQueuedEventIterator.remove();

            //record the current exception -> to check it at the next call or to use it on the error-page
            flash.put(throwable.getClass().getName(), throwable);
            flash.keep(throwable.getClass().getName());

            this.viewNavigationHandler.navigateTo(DefaultErrorView.class);

            break;
        }
    }

    this.wrapped.handle();
}
项目:ums    文件:FacesUtil.java   
public static void keepFlashMessages() {
    FacesContext context = FacesContext.getCurrentInstance();
    Flash flash = context.getExternalContext().getFlash();
    flash.setKeepMessages(true);
    flash.setRedirect(true);
}
项目:nemo-utils    文件:JSFController.java   
/**
 * Obtains the JSF Flash object.
 * 
 * @return The Flash object associated with the current request.
 */
protected Flash getFlash() {
    return getExternalContext().getFlash();
}