Refine search
public static void setCurrentInstance(PrimeRequestContext context, FacesContext facesContext) { if (context == null) { if (facesContext != null) { facesContext.getAttributes().remove(INSTANCE_KEY); } } else { facesContext.getAttributes().put(INSTANCE_KEY, context); } }
protected FaceletContext getFaceletContext(FacesContext context) { FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); if (faceletContext == null) { faceletContext = (FaceletContext) context.getAttributes().get("com.sun.faces.facelets.FACELET_CONTEXT"); } return faceletContext; }
public static void putInitialResources(FacesContext context, List<ResourceUtils.ResourceInfo> resources) { context.getAttributes().put(INITIAL_RESOURCES, resources); }
/** * @return all scripts added in the current request. */ @SuppressWarnings("unchecked") public List<String> getScriptsToExecute() { List<String> scriptsToExecute = (List<String>) context.getAttributes().get(EXECUTE_SCRIPT_KEY); if (scriptsToExecute == null) { scriptsToExecute = new ArrayList<>(); context.getAttributes().put(EXECUTE_SCRIPT_KEY, scriptsToExecute); } return scriptsToExecute; }
@Override public void processEvent(SystemEvent cse) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); Timeline timeline = (Timeline) cse.getSource(); String widgetVar = timeline.resolveWidgetVar(); Map<String, TimelineUpdater> map = (Map<String, TimelineUpdater>) context.getAttributes().get(TimelineUpdater.class.getName()); if (map == null) { map = new HashMap<>(); context.getAttributes().put(TimelineUpdater.class.getName(), map); } boolean alreadyRegistred = false; for (PhaseListener listener : context.getViewRoot().getPhaseListeners()) { if (listener instanceof DefaultTimelineUpdater && ((DefaultTimelineUpdater) listener).getWidgetVar().equals(widgetVar)) { if (!map.containsKey(widgetVar)) { map.put(widgetVar, (DefaultTimelineUpdater) listener); } alreadyRegistred = true; } } if (!alreadyRegistred) { DefaultTimelineUpdater timelineUpdater = new DefaultTimelineUpdater(); timelineUpdater.setWidgetVar(widgetVar); map.put(widgetVar, timelineUpdater); context.getViewRoot().addPhaseListener(timelineUpdater); } }
public static void setResetFlowHandlerStateIfUnset(FacesContext facesContext, boolean resetFlowHandlerState) { Map<Object, Object> attributes = facesContext.getAttributes(); if (!attributes.containsKey(RESET_FLOW_HANDLER_STATE_KEY)) { attributes.put(RESET_FLOW_HANDLER_STATE_KEY, resetFlowHandlerState); } }
@Override public void handleNavigation(FacesContext context, String fromAction, String outcome) { Map<Object, Object> attrs = context.getAttributes(); String dialogOutcome = (String) attrs.get(Constants.DIALOG_FRAMEWORK.OUTCOME); NavigationCase navCase = getNavigationCase(context, fromAction, dialogOutcome); String toViewId = navCase.getToViewId(context); Map<String, Object> options = (Map<String, Object>) attrs.get(Constants.DIALOG_FRAMEWORK.OPTIONS); Map<String, List<String>> params = (Map<String, List<String>>) attrs.get(Constants.DIALOG_FRAMEWORK.PARAMS); if (options != null && options.containsKey(Constants.DIALOG_FRAMEWORK.INCLUDE_VIEW_PARAMS)) { includeViewParams = (Boolean) options.get(Constants.DIALOG_FRAMEWORK.INCLUDE_VIEW_PARAMS);
private static void _clearVisitedFacetCountMap(FacesContext facesContext) { Map<UIComponent, Integer> visitedFacetCount = (Map<UIComponent, Integer>) facesContext.getAttributes().get(VISITED_FACET_COUNT_KEY); if (visitedFacetCount != null) { visitedFacetCount.clear(); facesContext.getAttributes().remove(VISITED_FACET_COUNT_KEY); } }
@Override public void markInitialState() { if (isRowStatePreserved()) { if (getFacesContext().getAttributes().containsKey(StateManager.IS_BUILDING_INITIAL_STATE)) { _initialDescendantFullComponentState = saveDescendantInitialComponentStates(getFacesContext(), getChildren().iterator(), false); } } super.markInitialState(); }
private int getAndClearMaxReturnDepth(FacesContext context) { Map<Object, Object> attrs = context.getAttributes(); int result = 0; if (attrs.containsKey(FLOW_RETURN_DEPTH_PARAM_NAME)) { result = ((Integer)attrs.remove(FLOW_RETURN_DEPTH_PARAM_NAME)).intValue(); } return result; }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { context.getResponseWriter().endElement("div"); context.getAttributes().remove(Constants.FRAGMENT_ID); } }
/** * @return all callback parameters added in the current request. */ @SuppressWarnings("unchecked") public Map<String, Object> getCallbackParams() { Map<String, Object> callbackParams = (Map<String, Object>) context.getAttributes().get(CALLBACK_PARAMS_KEY); if (callbackParams == null) { callbackParams = new HashMap<>(); context.getAttributes().put(CALLBACK_PARAMS_KEY, callbackParams); } return callbackParams; }
private void incrementMaxReturnDepth() { FacesContext context = FacesContext.getCurrentInstance(); Map<Object, Object> attrs = context.getAttributes(); if (!attrs.containsKey(FLOW_RETURN_DEPTH_PARAM_NAME)) { attrs.put(FLOW_RETURN_DEPTH_PARAM_NAME, (Integer) 1); } else { Integer cur = (Integer) attrs.get(FLOW_RETURN_DEPTH_PARAM_NAME); attrs.put(FLOW_RETURN_DEPTH_PARAM_NAME, (Integer) cur + 1); } }
public void encodeStaticBody(FacesContext context, PanelGrid grid) throws IOException { context.getAttributes().put(Constants.HELPER_RENDERER, "panelGridBody"); int i = 0; for (UIComponent child : grid.getChildren()) { if (child.isRendered()) { if (child instanceof Row) { String rowStyleClass = i % 2 == 0 ? PanelGrid.TABLE_ROW_CLASS + " " + PanelGrid.EVEN_ROW_CLASS : PanelGrid.TABLE_ROW_CLASS + " " + PanelGrid.ODD_ROW_CLASS; encodeRow(context, (Row) child, "gridcell", rowStyleClass, PanelGrid.CELL_CLASS); i++; } else { child.encodeAll(context); } } } context.getAttributes().remove(Constants.HELPER_RENDERER); }
public static void setResetFlowHandlerStateIfUnset(FacesContext facesContext, boolean resetFlowHandlerState) { Map<Object, Object> attributes = facesContext.getAttributes(); if (!attributes.containsKey(RESET_FLOW_HANDLER_STATE_KEY)) { attributes.put(RESET_FLOW_HANDLER_STATE_KEY, resetFlowHandlerState); } }
public static List<ResourceUtils.ResourceInfo> getInitialResources(FacesContext context) { return (List<ResourceUtils.ResourceInfo>) context.getAttributes().get(INITIAL_RESOURCES); }
static boolean wholeBeanValidationEnabled(FacesContext context, Class [] validationGroupsArray) { boolean result; Map<Object,Object> attrs = context.getAttributes(); if (!(attrs.containsKey(ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME) && (Boolean)attrs.get(ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME))) { // NOPMD return false; } result = !(1 == validationGroupsArray.length && Default.class == validationGroupsArray[0]); return result; }
/** * Opens a view in a dynamic dialog. * * @param outcome the logical outcome used to resolve the navigation case. * @param options configuration options for the dialog. * @param params parameters to send to the view displayed in the dynamic dialog. */ public void openDynamic(String outcome, Map<String, Object> options, Map<String, List<String>> params) { FacesContext facesContext = getFacesContext(); facesContext.getAttributes().put(Constants.DIALOG_FRAMEWORK.OUTCOME, outcome); if (options != null) { facesContext.getAttributes().put(Constants.DIALOG_FRAMEWORK.OPTIONS, options); } if (params != null) { facesContext.getAttributes().put(Constants.DIALOG_FRAMEWORK.PARAMS, params); } }
private static void _removeVisitedFacetCount(FacesContext facesContext, UIComponent component) { Map<UIComponent, Integer> visitedFacetCount = (Map<UIComponent, Integer>) facesContext.getAttributes().get(VISITED_FACET_COUNT_KEY); if (visitedFacetCount == null) { return; } visitedFacetCount.remove(component); }
/** * @param ctx the {@link FacesContext} for the current request * @param viewToRender the {@link UIViewRoot} to check * @return <code>true</code> if the {@link FacesContext} attributes map * contains a reference to the {@link UIViewRoot}'s view ID */ public static boolean isViewPopulated(FacesContext ctx, UIViewRoot viewToRender) { return ctx.getAttributes().containsKey(viewToRender); }