public static PrimeApplicationContext getCurrentInstance(FacesContext facesContext) { if (facesContext == null || facesContext.getExternalContext() == null) { return null; } PrimeApplicationContext applicationContext = (PrimeApplicationContext) facesContext.getExternalContext().getApplicationMap().get(INSTANCE_KEY); if (applicationContext == null) { applicationContext = new PrimeApplicationContext(facesContext); setCurrentInstance(applicationContext, facesContext); } return applicationContext; }
public AjaxRequestBuilder resetValues(boolean value, boolean resetValuesSet) { PrimeConfiguration config = PrimeApplicationContext.getCurrentInstance(context).getConfig(); //component can override global setting boolean resetValues = resetValuesSet ? value : config.isResetValuesEnabled(); if (resetValues) { buffer.append(",rv:true"); } return this; }
/** * 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; }
@Override public void processEvent(SystemEvent event) throws AbortProcessingException { PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()); if (applicationContext != null) { applicationContext.release(); } } }
@SuppressWarnings("deprecation") // the default constructor is deprecated in JSF 2.3 public PrimeResource(final Resource resource) { super(); wrapped = resource; version = "&v=" + PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()).getEnvironment().getBuildVersion(); }
@Override public void decode(FacesContext context, UIComponent component) { if (!context.getExternalContext().getRequestContentType().toLowerCase().startsWith("multipart/")) { return; } FileUpload fileUpload = (FileUpload) component; if (!fileUpload.isDisabled()) { PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(context); String uploader = applicationContext.getConfig().getUploader(); boolean isAtLeastJSF22 = applicationContext.getEnvironment().isAtLeastJsf22(); String inputToDecodeId = getSimpleInputDecodeId(fileUpload, context); if (uploader.equals("auto")) { if (isAtLeastJSF22) { NativeFileUploadDecoder.decode(context, fileUpload, inputToDecodeId); } else { CommonsFileUploadDecoder.decode(context, fileUpload, inputToDecodeId); } } else if (uploader.equals("native")) { if (!isAtLeastJSF22) { throw new FacesException("native uploader requires at least a JSF 2.2 runtime"); } NativeFileUploadDecoder.decode(context, fileUpload, inputToDecodeId); } else if (uploader.equals("commons")) { CommonsFileUploadDecoder.decode(context, fileUpload, inputToDecodeId); } } }
public static void performVirusScan(FacesContext facesContext, FileUpload fileUpload, InputStream inputStream) throws VirusException { if (fileUpload.isPerformVirusScan()) { PrimeApplicationContext.getCurrentInstance(facesContext).getVirusScannerService().performVirusScan(inputStream); } }
= PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()).getEnumCacheMap();
public static void execute(PrimeApplicationContext applicationContext, UIComponent component) throws IOException { if (applicationContext.getConfig().isTransformMetadataEnabled()) { FacesContext context = FacesContext.getCurrentInstance(); if (applicationContext.getConfig().isBeanValidationEnabled()) { BV_INPUT_METADATA_TRANSFORMER.transform(context, applicationContext, component); } if (!METADATA_TRANSFORMERS.isEmpty()) { for (int i = 0; i < METADATA_TRANSFORMERS.size(); i++) { METADATA_TRANSFORMERS.get(i).transform(context, applicationContext, component); } } } }
applicationContext.getConfig().isInterpolateClientSideValidationMessages(); messageInterpolator = applicationContext.getValidatorFactory().getMessageInterpolator();
CacheProvider cacheProvider = PrimeApplicationContext.getCurrentInstance(context).getCacheProvider(); String key = uiCache.getKey(); String region = uiCache.getRegion();
/** * @return ApplicationContext instance. */ public PrimeApplicationContext getApplicationContext() { if (this.applicationContext == null) { this.applicationContext = PrimeApplicationContext.getCurrentInstance(context); } return applicationContext; }
public static PropertyDescriptor extractPropertyDescriptor(FacesContext context, PrimeApplicationContext applicationContext, ValueExpression ve) { if (ve != null) { ELContext elContext = context.getELContext(); ValueReference vr = ValueExpressionAnalyzer.getReference(elContext, ve); if (vr != null) { Validator validator = applicationContext.getValidator(); Object base = vr.getBase(); Object property = vr.getProperty(); if (base != null && property != null) { BeanDescriptor beanDescriptor = validator.getConstraintsForClass(base.getClass()); if (beanDescriptor != null) { return beanDescriptor.getConstraintsForProperty(property.toString()); } } } } return null; } }
protected void renderDynamicPassThruAttributes(FacesContext context, UIComponent component) throws IOException { if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) { Jsf22Helper.renderPassThroughAttributes(context, component); } }
/** * @return Shared WidgetBuilder instance of the current request */ public WidgetBuilder getWidgetBuilder() { if (this.widgetBuilder == null) { this.widgetBuilder = new WidgetBuilder(context, getApplicationContext().getConfig()); } return widgetBuilder; }
@Override public void processEvent(SystemEvent event) throws AbortProcessingException { try { if (event instanceof PreRenderComponentEvent) { PreRenderComponentEvent preRenderComponentEvent = (PreRenderComponentEvent) event; execute(PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()), preRenderComponentEvent.getComponent()); } } catch (IOException e) { throw new FacesException(e); } }
public AjaxRequestBuilder partialSubmit(boolean value, boolean partialSubmitSet, String partialSubmitFilter) { PrimeConfiguration config = PrimeApplicationContext.getCurrentInstance(context).getConfig(); //component can override global setting boolean partialSubmit = partialSubmitSet ? value : config.isPartialSubmitEnabled(); if (partialSubmit) { buffer.append(",ps:true"); if (partialSubmitFilter != null) { buffer.append(",psf:\"").append(partialSubmitFilter).append("\""); } } return this; }
public static boolean isSkipIteration(VisitContext visitContext, FacesContext context) { if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf21()) { return visitContext.getHints().contains(VisitHint.SKIP_ITERATION); } else { Boolean skipIterationHint = (Boolean) visitContext.getFacesContext().getAttributes().get(SKIP_ITERATION_HINT); return skipIterationHint != null && skipIterationHint.booleanValue() == true; } }
@SuppressWarnings("deprecation") // the default constructor is deprecated in JSF 2.3 public PrimeFacesContext(FacesContext wrapped) { this.wrapped = wrapped; PrimeRequestContext requestContext = new PrimeRequestContext(wrapped); PrimeRequestContext.setCurrentInstance(requestContext, wrapped); moveScriptsToBottom = requestContext.getApplicationContext().getConfig().isMoveScriptsToBottom(); if (moveScriptsToBottom) { moveScriptsToBottomState = new MoveScriptsToBottomState(); } }
protected boolean isBeanValidationDefined(UIInput input, FacesContext context) { try { PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(context); Set<ConstraintDescriptor<?>> constraints = BeanValidationMetadataExtractor.extractDefaultConstraintDescriptors(context, applicationContext, return applicationContext.getConfig().isInterpretEmptyStringAsNull();