@Override public ExternalContext getObject() { return FacesContext.getCurrentInstance().getExternalContext(); } @Override
public <T> T eval(String attr, T unspecifiedValue) { if (literals.containsKey(attr)) { Object val = literals.get(attr); if (val == null) { return unspecifiedValue; } else { return (T) val; } } ValueExpression ve = bindings.get(attr); if (ve != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); return (T) ve.getValue(elContext); } return unspecifiedValue; }
@Override public Object getValue(ELContext elContext, Object base, Object property) { if (EL_NAME.equals(property)) { elContext.setPropertyResolved(true); FacesContext context = FacesContext.getCurrentInstance(); ExceptionInfo info = (ExceptionInfo) context.getAttributes().get(ExceptionInfo.ATTRIBUTE_NAME); if (info == null) { info = (ExceptionInfo) context.getExternalContext().getSessionMap().get(ExceptionInfo.ATTRIBUTE_NAME); } return info; } return null; }
@Override public void queueEvent(FacesEvent event) { FacesContext context = FacesContext.getCurrentInstance(); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM); String clientId = getClientId(context); DateUtils.toUtcDate(browserTZ, targetTZ, params.get(clientId + "_startDate")), DateUtils.toUtcDate(browserTZ, targetTZ, params.get(clientId + "_endDate")), getGroup(params.get(clientId + "_group"))); te.setPhaseId(behaviorEvent.getPhaseId());
/** * Get all constants of the given {@link Class}. * * @param facesContext The {@link FacesContext}. * @param type The class which includes the constants. * @return A {@link Map} with the constants. */ protected Map<String, Object> getConstants(FacesContext facesContext, Class<?> type) { boolean cacheEnabled = facesContext.isProjectStage(ProjectStage.Production); Map<Class<?>, Map<String, Object>> cache = PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()).getConstantsCacheMap(); Map<String, Object> constants; if (cacheEnabled && cache.containsKey(type)) { constants = cache.get(type); } else { constants = Collections.unmodifiableMap(collectConstants(type)); if (cacheEnabled) { cache.put(type, constants); } } return constants; }
@PostConstruct public void init() { storageMap = new ConcurrentHashMap<String, ViewScopeContextualStorage>(); FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.getExternalContext().getSessionMap().put(VIEW_SCOPE_PREFIX_KEY, 1); }
protected ResourceBundle getFacesResourceBundle(Locale locale) { ResourceBundle facesResourceBundle = facesResourceBundleMap.get(locale); if (facesResourceBundle == null) { String messageBundle = FacesContext.getCurrentInstance().getApplication().getMessageBundle(); if (messageBundle == null) { messageBundle = FacesMessage.FACES_MESSAGES; } facesResourceBundle = ResourceBundle.getBundle(messageBundle, locale); facesResourceBundleMap.put(locale, facesResourceBundle); } return facesResourceBundle; }
@Override public void processAction(ActionEvent event) throws AbortProcessingException { UIComponent source = event.getComponent(); // don't use event#getFacesContext() - it's only available in JSF 2.3 Map<Object, Object> attrs = FacesContext.getCurrentInstance().getAttributes(); if (source instanceof Widget) { attrs.put(Constants.DIALOG_FRAMEWORK.SOURCE_WIDGET, ((Widget) source).resolveWidgetVar()); } attrs.put(Constants.DIALOG_FRAMEWORK.SOURCE_COMPONENT, source.getClientId()); base.processAction(event); }
public int compare(Object obj1, Object obj2) { try { FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getRequestMap().put(var, obj1); Object value1 = sortBy.getValue(context.getELContext()); context.getExternalContext().getRequestMap().put(var, obj2); Object value2 = sortBy.getValue(context.getELContext()); result = (Integer) sortFunction.invoke(context.getELContext(), new Object[]{value1, value2});
/** * Gets the current thread-safe TimelineUpdater instance by Id. * * @param id Id of the Timeline component in terms of findComponent() * @return TimelineUpdater instance. * @throws FacesException if the Timeline component can not be found by the given Id */ public static TimelineUpdater getCurrentInstance(String id) { FacesContext fc = FacesContext.getCurrentInstance(); @SuppressWarnings("unchecked") Map<String, TimelineUpdater> map = (Map<String, TimelineUpdater>) fc.getAttributes().get(TimelineUpdater.class.getName()); if (map == null) { return null; } UIComponent timeline = fc.getViewRoot().findComponent(id); if (timeline == null || !(timeline instanceof Timeline)) { throw new FacesException("Timeline component with Id " + id + " was not found"); } TimelineUpdater timelineUpdater = map.get(((Timeline) timeline).resolveWidgetVar()); if (timelineUpdater != null) { timelineUpdater.id = id; } return timelineUpdater; }
protected Cookie getCookie(String name) { return (Cookie) FacesContext.getCurrentInstance().getExternalContext() .getRequestCookieMap().get(name); }
@Override public String getSummary() { FacesContext facesContext = FacesContext.getCurrentInstance(); ValueExpression value = facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), super.getSummary(), String.class); return (String)value.getValue(facesContext.getELContext()); }
public boolean isPortletEnvironment() { boolean portletEnvironment = false; Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest(); if (request != null) { if (request instanceof PortletRequest) { portletEnvironment = true; } } return portletEnvironment; }
@Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { if (value == null) { throw new AbortProcessingException("Value has not been set"); } ELContext elContext = FacesContext.getCurrentInstance().getELContext(); Object val = value.getValue(elContext); if (addTo != null) { Collection collection = (Collection) addTo.getValue(elContext); Object uniqueValue = (unique != null) ? unique.getValue(elContext) : null; boolean checkUniqueness = (uniqueValue == null) ? true : Boolean.parseBoolean(uniqueValue.toString()); if (checkUniqueness) { if (!collection.contains(val)) { collection.add(val); } } else { collection.add(val); } } else if (removeFrom != null) { Collection collection = (Collection) removeFrom.getValue(elContext); collection.remove(val); } else { throw new IllegalArgumentException("Specify either addTo or removeFrom as collection reference"); } }
public ValidateLengthTag() { super(); if (VALIDATOR_ID_EXPR == null) { FacesContext context = FacesContext.getCurrentInstance(); ExpressionFactory factory = context.getApplication(). getExpressionFactory(); VALIDATOR_ID_EXPR = factory.createValueExpression(context.getELContext(), "javax.faces.Length", String.class); } }
@Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); StreamedContent content = (StreamedContent) value.getValue(elContext); ExternalContext externalContext = context.getExternalContext(); String contentDispositionValue = contentDisposition != null ? (String) contentDisposition.getValue(elContext) : "attachment"; String monitorKeyValue = monitorKey != null ? "_" + (String) monitorKey.getValue(elContext) : "";
@Override public boolean isAjaxRequest() { return getWrapped().isAjaxRequest() || FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().containsKey("javax.faces.partial.ajax"); }
public static void addSearchKeywordResolvers() { FacesContext.getCurrentInstance() .getApplication() .addSearchKeywordResolver(new Jsf23WidgetVarSearchKeywordResolver()); } }
@Override public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); final ELContext elContext = context.getELContext(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Try to invoke listener: " + listener.getExpressionString()); } try { listener.invoke(elContext, new Object[]{}); } catch (MethodNotFoundException | IllegalArgumentException | ArrayIndexOutOfBoundsException mnfe) { processArgListener(context, elContext, event); } }
/** * Get processDefinitionId and callbackUrl from request and start a conversation * to start the form * */ public void startProcessInstanceByIdForm() { if (FacesContext.getCurrentInstance().isPostback()) { // if this is an AJAX request ignore it, since we will receive multiple calls to this bean if it is added // as preRenderView event // see http://stackoverflow.com/questions/2830834/jsf-fevent-prerenderview-is-triggered-by-fajax-calls-and-partial-renders-some return; } Map<String, String> requestParameterMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); String processDefinitionId = requestParameterMap.get("processDefinitionId"); String callbackUrl = requestParameterMap.get("callbackUrl"); this.url = callbackUrl; this.processDefinitionId = processDefinitionId; beginConversation(); }