public static PhaseInfo getPhaseInfo(PhaseId id, FacesContext facesContext) { Map<String, Object> session = facesContext.getExternalContext().getSessionMap(); Map<String, LinkedHashMap<Integer, PhaseInfo>> storePerView = (Map<String, LinkedHashMap<Integer, PhaseInfo>>) session.get(LifecyclePhaseListener.class.getName()); if (storePerView == null) { storePerView = new HashMap<>(); session.put(LifecyclePhaseListener.class.getName(), storePerView); } String viewId = ComponentUtils.calculateViewId(facesContext); LinkedHashMap<Integer, PhaseInfo> store = storePerView.get(viewId); if (store == null) { store = new LinkedHashMap<>(); storePerView.put(viewId, store); } PhaseInfo phaseInfo = store.get(id.getOrdinal()); if (phaseInfo == null) { phaseInfo = new PhaseInfo(); phaseInfo.setPhase(id.getOrdinal()); store.put(id.getOrdinal(), phaseInfo); } return phaseInfo; }
/** * Builds the view if not already available. This is mostly required for ViewExpiredException's. * * @param context The {@link FacesContext}. * @param throwable The occurred {@link Throwable}. * @param rootCause The root cause. * @return The unwrapped {@link Throwable}. * @throws java.io.IOException If building the view fails. */ protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException { if (context.getViewRoot() == null) { ViewHandler viewHandler = context.getApplication().getViewHandler(); String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context)); ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId); UIViewRoot viewRoot = vdl.createView(context, viewId); context.setViewRoot(viewRoot); vdl.buildView(context, viewRoot); // Workaround for Mojarra // if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException' if (rootCause == null && throwable instanceof IllegalArgumentException) { rootCause = new javax.faces.application.ViewExpiredException(viewId); } } return rootCause; }
public static PhaseInfo getPhaseInfo(PhaseId id, FacesContext facesContext) { Map<String, Object> session = facesContext.getExternalContext().getSessionMap(); Map<String, LinkedHashMap<Integer, PhaseInfo>> storePerView = (Map<String, LinkedHashMap<Integer, PhaseInfo>>) session.get(LifecyclePhaseListener.class.getName()); if (storePerView == null) { storePerView = new HashMap<String, LinkedHashMap<Integer, PhaseInfo>>(); session.put(LifecyclePhaseListener.class.getName(), storePerView); } String viewId = ComponentUtils.calculateViewId(facesContext); LinkedHashMap<Integer, PhaseInfo> store = storePerView.get(viewId); if (store == null) { store = new LinkedHashMap<Integer, PhaseInfo>(); storePerView.put(viewId, store); } PhaseInfo phaseInfo = store.get(id.getOrdinal()); if (phaseInfo == null) { phaseInfo = new PhaseInfo(); phaseInfo.setPhase(id.getOrdinal()); store.put(id.getOrdinal(), phaseInfo); } return phaseInfo; }
/** * Builds the view if not already available. This is mostly required for ViewExpiredException's. * * @param context The {@link FacesContext}. * @param throwable The occurred {@link Throwable}. * @param rootCause The root cause. * @return The unwrapped {@link Throwable}. * @throws java.io.IOException If building the view fails. */ protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException { if (context.getViewRoot() == null) { ViewHandler viewHandler = context.getApplication().getViewHandler(); String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context)); ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId); UIViewRoot viewRoot = vdl.createView(context, viewId); context.setViewRoot(viewRoot); vdl.buildView(context, viewRoot); // Workaround for Mojarra // if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException' if (rootCause == null && throwable instanceof IllegalArgumentException) { rootCause = new javax.faces.application.ViewExpiredException(viewId); } } return rootCause; }