@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(); }
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; } }
protected void renderDynamicPassThruAttributes(FacesContext context, UIComponent component) throws IOException { if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) { Jsf22Helper.renderPassThroughAttributes(context, component); } }
if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) { String toFlowDocumentId = navCase.getToFlowDocumentId(); if (toFlowDocumentId != null) {
protected NavigationCase findNavigationCase(FacesContext context, UIOutcomeTarget outcomeTarget) { ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler(); String outcome = outcomeTarget.getOutcome(); if (outcome == null) { outcome = context.getViewRoot().getViewId(); } if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) { if (outcomeTarget instanceof UIComponent) { String toFlowDocumentId = (String) ((UIComponent) outcomeTarget).getAttributes().get(ActionListener.TO_FLOW_DOCUMENT_ID_ATTR_NAME); if (toFlowDocumentId != null) { return navigationHandler.getNavigationCase(context, null, outcome, toFlowDocumentId); } } } return navigationHandler.getNavigationCase(context, null, outcome); }
@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); } } }
protected void renderPassThruAttributes(FacesContext context, UIComponent component, String[] attrs, String[] ignoredAttrs) throws IOException { ResponseWriter writer = context.getResponseWriter(); //pre-defined attributes for (String attribute : attrs) { if (isIgnoredAttribute(attribute, ignoredAttrs)) { continue; } Object value = component.getAttributes().get(attribute); if (shouldRenderAttribute(value)) { writer.writeAttribute(attribute, value.toString(), attribute); } } //dynamic attributes if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) { Jsf22Helper.renderPassThroughAttributes(context, component); } }
if (applicationContext.getEnvironment().isAtLeastJsf23()) { && !applicationContext.getEnvironment().isAtLeastJsf23()) { List<ResourceUtils.ResourceInfo> initialResources = DynamicResourcesPhaseListener.getInitialResources(context); List<ResourceUtils.ResourceInfo> currentResources = ResourceUtils.getComponentResources(context);
public static ValueExpression getExpression(ELContext elContext, ValueExpression expression) { if (expression == null) { return null; } // Unwrapping is required e.g. for p:graphicImage to support nested expressions in composites // The unwrapping requires EL 2.2 if (PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()).getEnvironment().isAtLeastEl22()) { ValueReference reference = toValueReference(expression, elContext); // check for a CC expression if (reference != null && isCompositeComponentReference(reference)) { ValueExpression unwrapped = unwrapCompositeComponentReference(reference); if (unwrapped != null) { // check for nested CC expressions if (isCompositeComponentReference(toValueReference(unwrapped, elContext))) { return getExpression(elContext, unwrapped); } else { return unwrapped; } } } } return expression; }
@Override public void afterPhase(PhaseEvent event) { FacesContext context = event.getFacesContext(); // we only need to collect resources on ajax requests // for non ajax, the head will always be rendered again if (context.getViewRoot() == null || !context.getPartialViewContext().isAjaxRequest()) { return; } // we can also skip non-postback ajax requests, which occurs e.g. without a form if (!context.isPostback()) { return; } // skip update=@all as the head, with all resources, will already be rendered if (context.getPartialViewContext().isRenderAll()) { return; } // JSF 2.3 contains a own dynamic resource handling if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf23()) { return; } // collect all current resources before new components can be added to the view in later phases List<ResourceUtils.ResourceInfo> initialResources = ResourceUtils.getComponentResources(context); putInitialResources(context, initialResources); }
@Override public void decode(FacesContext context, UIComponent component) { TextEditor editor = (TextEditor) component; if (!shouldDecode(editor)) { return; } decodeBehaviors(context, editor); String inputParam = editor.getClientId(context) + "_input"; Map<String, String> params = context.getExternalContext().getRequestParameterMap(); String value = params.get(inputParam); if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isHtmlSanitizerAvailable()) { value = HtmlSanitizer.sanitizeHtml(value, editor.isAllowBlocks(), editor.isAllowFormatting(), editor.isAllowLinks(), editor.isAllowStyles(), editor.isAllowImages()); } else { if (!editor.isAllowBlocks() || !editor.isAllowFormatting() || !editor.isAllowLinks() || !editor.isAllowStyles() || !editor.isAllowImages()) { LOGGER.warning("HTML sanitizer not available - skip sanitizing...."); } } if (value != null && value.equals("<br/>")) { value = ""; } editor.setSubmittedValue(value); }
PrimeEnvironment environment = PrimeApplicationContext.getCurrentInstance(context).getEnvironment(); if (environment.isMojarra()) { addAttachedObjectHandlerToMojarra(environment, parent);
if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22() && outcomeTarget.isDisableClientWindow()) {