/** * @param context the <code>FacesContext</code> for the current request * * @return <code>true</code> If the <code>add/remove</code> javascript * has been rendered, otherwise <code>false</code> */ public static boolean hasScriptBeenRendered(FacesContext context) { return RequestStateManager.containsKey(context, RequestStateManager.SCRIPT_STATE); }
/** * Indicates that the specified ResourceDependency has been processed. * @param ctx the {@link FacesContext} for the current request * @param dep the {@link ResourceDependency} */ @SuppressWarnings({"unchecked"}) private void markProcssed(FacesContext ctx, ResourceDependency dep) { Set<ResourceDependency> dependencies = (Set<ResourceDependency>) RequestStateManager.get(ctx, RequestStateManager.PROCESSED_RESOURCE_DEPENDENCIES); if (dependencies == null) { dependencies = new HashSet<ResourceDependency>(6); RequestStateManager.set(ctx, RequestStateManager.PROCESSED_RESOURCE_DEPENDENCIES, dependencies); } dependencies.add(dep); }
/** * @param ctx the <code>FacesContext</code> for the current request * @param key the key for the value * @return the value associated with the specified key. */ public static Object get(FacesContext ctx, String key) { if (ctx == null || key == null) { return null; } Map<String,Object> reqState = getStateMap(ctx); return reqState.get(key); }
/** * <p> * Adds the specified key and value to the Map stored in the request. * If <code>value</code> is <code>null</code>, that key/value pair will * be removed from the Map. * </p> * * @param ctx the <code>FacesContext</code> for the current request * @param key the key for the value * @param value the value to store */ public static void set(FacesContext ctx, String key, Object value) { if (ctx == null || key == null) { return; } if (value == null) { remove(ctx, key); } Map<String,Object> reqState = getStateMap(ctx); reqState.put(key, value); }
public void release() { RequestStateManager.remove(this, RequestStateManager.FACESCONTEXT_IMPL_ATTR_NAME); RequestStateManager.remove(this, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED); released = true; externalContext = null; responseStream = null; responseWriter = null; componentMessageLists = null; renderResponse = false; responseComplete = false; viewRoot = null; // PENDING(edburns): write testcase that verifies that release // actually works. This will be important to keep working as // ivars are added and removed on this class over time. // Make sure to clear our ThreadLocal instance. setCurrentInstance(null); }
/** @see {@link ResponseStateManager#getComponentStateToRestore(javax.faces.context.FacesContext)} */ @Override @SuppressWarnings("deprecation") public Object getComponentStateToRestore(FacesContext context) { return RequestStateManager.get(context, RequestStateManager.FACES_VIEW_STATE); }
public static boolean isJsfJsInstalled(FacesContext context) { if (RequestStateManager.containsKey(context, RequestStateManager.SCRIPT_STATE)) { return true; } UIViewRoot viewRoot = context.getViewRoot(); for (UIComponent resource : viewRoot.getComponentResources(context)) { Object name = resource.getAttributes().get("name"); Object library = resource.getAttributes().get("library"); if (JSF_SCRIPT_RESOURCE_NAME.equals(name) && JSF_SCRIPT_LIBRARY_NAME.equals(library)) { RequestStateManager.set(context, RequestStateManager.SCRIPT_STATE, true); return true; } } return false; }
clientIds.add(clientIdIter.next()); RequestStateManager.set(facesContext, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED, clientIds); RequestStateManager.containsKey(facesContext, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED)) { (Set) RequestStateManager.remove(facesContext, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED), String.class);
private static void storeStructureInRequest(FacesContext context, Object structure) { RequestStateManager.set(context, RequestStateManager.FACES_VIEW_STRUCTURE, structure); }
public Iterator<FacesMessage> getMessages() { assertNotReleased(); if (null == componentMessageLists) { List<FacesMessage> emptyList = Collections.emptyList(); return (emptyList.iterator()); } //Clear set of clientIds from pending display messages list. if (RequestStateManager.containsKey(this, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED)) { Set pendingClientIds = (Set) RequestStateManager.get(this, RequestStateManager.CLIENT_ID_MESSAGES_NOT_DISPLAYED); pendingClientIds.clear(); } if (componentMessageLists.size() > 0) { return new ComponentMessagesIterator(componentMessageLists); } else { List<FacesMessage> emptyList = Collections.emptyList(); return (emptyList.iterator()); } }
/** * @see FacesContext#setViewRoot(javax.faces.component.UIViewRoot) */ @Override public void setViewRoot(UIViewRoot root) { assertNotReleased(); Util.notNull("root", root); if (viewRoot != null && !viewRoot.equals(root)) { Map<String, Object> viewMap = viewRoot.getViewMap(false); if (viewMap != null) { viewRoot.getViewMap().clear(); } RequestStateManager.clearAttributesOnChangeOfView(this); } viewRoot = root; }
RequestStateManager.clearAttributesForPhase(context, context.getCurrentPhaseId()); while (listenersIterator.hasNext()) {
/** * <p> * Adds the specified key and value to the Map stored in the request. * If <code>value</code> is <code>null</code>, that key/value pair will * be removed from the Map. * </p> * * @param ctx the <code>FacesContext</code> for the current request * @param key the key for the value * @param value the value to store */ public static void set(FacesContext ctx, String key, Object value) { if (ctx == null || key == null) { return; } if (value == null) { remove(ctx, key); } ctx.getAttributes().put(key, value); }
/** * Return the {@link javax.faces.component.UIComponent} that is currently being processed. * * @return the current component, or null. */ protected UIComponent getComponent() { FacesContext context = FacesContext.getCurrentInstance(); if (context != null) { return ((UIComponent) RequestStateManager.get(context, RequestStateManager.TARGET_COMPONENT_ATTRIBUTE_NAME)); } return null; }
public static boolean isJsfJsInstalled(FacesContext context) { if (RequestStateManager.containsKey(context, RequestStateManager.SCRIPT_STATE)) { return true; } UIViewRoot viewRoot = context.getViewRoot(); for (UIComponent resource : viewRoot.getComponentResources(context)) { Object name = resource.getAttributes().get("name"); Object library = resource.getAttributes().get("library"); if (JSF_SCRIPT_RESOURCE_NAME.equals(name) && JSF_SCRIPT_LIBRARY_NAME.equals(library)) { RequestStateManager.set(context, RequestStateManager.SCRIPT_STATE, true); return true; } } return false; }
/** * <p>Set a flag to indicate that the <code>add/remove</code> javascript * has been rendered for the current form. * * @param context the <code>FacesContext</code> of the current request */ public static void setScriptAsRendered(FacesContext context) { RequestStateManager.set(context, RequestStateManager.SCRIPT_STATE, Boolean.TRUE); }
/** * @see FacesContext#setViewRoot(javax.faces.component.UIViewRoot) */ @Override public void setViewRoot(UIViewRoot root) { assertNotReleased(); Util.notNull("root", root); if (viewRoot != null && !viewRoot.equals(root)) { Map<String, Object> viewMap = viewRoot.getViewMap(false); if (viewMap != null) { viewRoot.getViewMap().clear(); } RequestStateManager.clearAttributesOnChangeOfView(this); } viewRoot = root; }
/** * Indicates that the specified ResourceDependency has been processed. * @param ctx the {@link FacesContext} for the current request * @param dep the {@link ResourceDependency} */ @SuppressWarnings({"unchecked"}) private void markProcssed(FacesContext ctx, ResourceDependency dep) { Set<ResourceDependency> dependencies = (Set<ResourceDependency>) RequestStateManager.get(ctx, RequestStateManager.PROCESSED_RESOURCE_DEPENDENCIES); if (dependencies == null) { dependencies = new HashSet<>(6); RequestStateManager.set(ctx, RequestStateManager.PROCESSED_RESOURCE_DEPENDENCIES, dependencies); } dependencies.add(dep); }
/** * @param ctx the <code>FacesContext</code> for the current request * @param key the key for the value * @return true if the specified key exists in the Map */ public static boolean containsKey(FacesContext ctx, String key) { if (ctx == null || key == null) { return false; } Map<String,Object> reqState = getStateMap(ctx); return reqState.containsKey(key); }
/** * <p> * Adds the specified key and value to the Map stored in the request. * If <code>value</code> is <code>null</code>, that key/value pair will * be removed from the Map. * </p> * * @param ctx the <code>FacesContext</code> for the current request * @param key the key for the value * @param value the value to store */ public static void set(FacesContext ctx, String key, Object value) { if (ctx == null || key == null) { return; } if (value == null) { remove(ctx, key); } ctx.getAttributes().put(key, value); }