/** * <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); }
private static void storeStructureInRequest(FacesContext context, Object structure) { RequestStateManager.set(context, RequestStateManager.FACES_VIEW_STRUCTURE, structure); }
/** * <p>Store the state for this request into a temporary attribute * within the same request.</p> * * @param context the <code>FacesContext</code> of the current request * @param state the view state */ private static void storeStateInRequest(FacesContext context, Object state) { // store the state object temporarily in request scope // until it is processed by getComponentStateToRestore // which resets it. RequestStateManager.set(context, RequestStateManager.FACES_VIEW_STATE, 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<>(6); RequestStateManager.set(ctx, RequestStateManager.PROCESSED_RESOURCE_DEPENDENCIES, dependencies); } dependencies.add(dep); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * @see ResourceHandler#isResourceRequest(javax.faces.context.FacesContext) */ @Override public boolean isResourceRequest(FacesContext context) { Boolean isResourceRequest = (Boolean) RequestStateManager.get(context, RESOURCE_REQUEST); if (isResourceRequest == null) { String resourceId = normalizeResourceRequest(context); isResourceRequest = (resourceId != null ? resourceId.startsWith(RESOURCE_IDENTIFIER) : FALSE); RequestStateManager.set(context, RESOURCE_REQUEST, isResourceRequest); } return isResourceRequest; }
/** * @see ResourceHandler#isResourceRequest(javax.faces.context.FacesContext) */ @Override public boolean isResourceRequest(FacesContext context) { Boolean isResourceRequest = (Boolean) RequestStateManager.get(context, RESOURCE_REQUEST); if (isResourceRequest == null) { String resourceId = normalizeResourceRequest(context); isResourceRequest = (resourceId != null ? resourceId.startsWith(RESOURCE_IDENTIFIER) : FALSE); RequestStateManager.set(context, RESOURCE_REQUEST, isResourceRequest); } return isResourceRequest; }
@Override public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if (component instanceof UISelectMany) { // Need to set the 'TARGET_COMPONENT_ATTRIBUTE_NAME' request attr so the // coerce-value call in the jsf-api UISelectMany.matchValue will work // (need a better way to determine the currently processing UIComponent ...) RequestStateManager.set(context, TARGET_COMPONENT_ATTRIBUTE_NAME, component); return convertSelectManyValue(context, ((UISelectMany) component), (String[]) submittedValue); } else { return convertSelectOneValue(context, ((UISelectOne) component), (String) submittedValue); } }
@Override public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if (component instanceof UISelectMany) { // Need to set the 'TARGET_COMPONENT_ATTRIBUTE_NAME' request attr so the // coerce-value call in the jsf-api UISelectMany.matchValue will work // (need a better way to determine the currently processing UIComponent ...) RequestStateManager.set(context, TARGET_COMPONENT_ATTRIBUTE_NAME, component); return convertSelectManyValue(context, ((UISelectMany) component), (String[]) submittedValue); } else { return convertSelectOneValue(context, ((UISelectOne) component), (String) submittedValue); } }
/** * @see ResourceHandler#isResourceRequest(javax.faces.context.FacesContext) */ @Override public boolean isResourceRequest(FacesContext context) { Boolean isResourceRequest = (Boolean) RequestStateManager.get(context, RESOURCE_REQUEST); if (isResourceRequest == null) { String resourceId = normalizeResourceRequest(context); isResourceRequest = (resourceId != null ? resourceId.startsWith(RESOURCE_IDENTIFIER) : FALSE); RequestStateManager.set(context, RESOURCE_REQUEST, isResourceRequest); } return isResourceRequest; }
@Override public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if (component instanceof UISelectMany) { // Need to set the 'TARGET_COMPONENT_ATTRIBUTE_NAME' request attr so the // coerce-value call in the jsf-api UISelectMany.matchValue will work // (need a better way to determine the currently processing UIComponent ...) RequestStateManager.set(context, TARGET_COMPONENT_ATTRIBUTE_NAME, component); return convertSelectManyValue(context, ((UISelectMany) component), (String[]) submittedValue); } else { return convertSelectOneValue(context, ((UISelectOne) component), (String) submittedValue); } }
/** * @see ResourceHandler#isResourceRequest(javax.faces.context.FacesContext) */ public boolean isResourceRequest(FacesContext context) { Boolean isResourceRequest = (Boolean) RequestStateManager.get(context, RequestStateManager.RESOURCE_REQUEST); if (isResourceRequest == null) { String resourceId = normalizeResourceRequest(context); isResourceRequest = (resourceId != null ? resourceId.startsWith(RESOURCE_IDENTIFIER) : Boolean.FALSE); RequestStateManager.set(context, RequestStateManager.RESOURCE_REQUEST, isResourceRequest); } return (isResourceRequest); }
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; }
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; }
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; }
@Override public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if (component instanceof UISelectMany) { // need to set the 'TARGET_COMPONENT_ATTRIBUTE_NAME' request attr so the // coerce-value call in the jsf-api UISelectMany.matchValue will work // (need a better way to determine the currently processing UIComponent ...) RequestStateManager.set(context, RequestStateManager.TARGET_COMPONENT_ATTRIBUTE_NAME, component); return convertSelectManyValue(context, ((UISelectMany) component), (String[]) submittedValue); } else { return convertSelectOneValue(context, ((UISelectOne) component), (String) submittedValue); } }
@Override public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if (component instanceof UISelectMany) { // need to set the 'TARGET_COMPONENT_ATTRIBUTE_NAME' request attr so the // coerce-value call in the jsf-api UISelectMany.matchValue will work // (need a better way to determine the currently processing UIComponent ...) RequestStateManager.set(context, RequestStateManager.TARGET_COMPONENT_ATTRIBUTE_NAME, component); return convertSelectManyValue(context, ((UISelectMany) component), (String[]) submittedValue); } else { return convertSelectOneValue(context, ((UISelectOne) component), (String) submittedValue); } }
/** * @see ResponseStateManager#getState(javax.faces.context.FacesContext, java.lang.String) */ @Override public Object getState(FacesContext context, String viewId) { Object state = RequestStateManager.get(context, RequestStateManager.FACES_VIEW_STATE); if (state == null) { try { state = helper.getState(context, viewId); if (state != null) { RequestStateManager.set(context, RequestStateManager.FACES_VIEW_STATE, state); } } catch (IOException e) { throw new FacesException(e); } } return state; }