protected boolean isLogException(FacesContext context, Throwable rootCause) { if (context.isProjectStage(ProjectStage.Production)) { if (rootCause instanceof ViewExpiredException) { return false; } } return true; }
public AjaxRequestBuilder delay(String delay) { if (!LangUtils.isValueBlank(delay) && !delay.equals("none")) { buffer.append(",d:").append(delay); if (context.isProjectStage(ProjectStage.Development)) { try { Integer.parseInt(delay); } catch (NumberFormatException e) { throw new FaceletException("Delay attribute should only take numbers or \"none\""); } } } return this; }
/** * Validates the given search expressions. We only validate it, for performance reasons, if the current {@link ProjectStage} is * {@link ProjectStage#Development}. * * @param context The {@link FacesContext}. * @param source The source component. E.g. a button. * @param expressions The search expression. * @param splittedExpressions The already splitted expressions. */ protected static void validateExpressions(FacesContext context, UIComponent source, String expressions, String[] splittedExpressions) { if (context.isProjectStage(ProjectStage.Development)) { if (splittedExpressions.length > 1) { if (expressions.contains(SearchExpressionConstants.NONE_KEYWORD) || expressions.contains(SearchExpressionConstants.ALL_KEYWORD)) { throw new FacesException("It's not possible to use @none or @all combined with other expressions." + " Expressions: \"" + expressions + "\" referenced from \"" + source.getClientId(context) + "\""); } } } }
/** * 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; }
protected static void validateRenderer(FacesContext context, UIComponent source, UIComponent component, String expression, int hints) { if (SearchExpressionUtils.isHintSet(hints, SearchExpressionHint.VALIDATE_RENDERER) && context.isProjectStage(ProjectStage.Development)) { if (LangUtils.isValueBlank(component.getRendererType())) { LOGGER.warning("Can not update component \"" + component.getClass().getName() + "\" with id \"" + component.getClientId(context) + "\" without a attached renderer. Expression \"" + expression + "\" referenced from \"" + source.getClientId(context) + "\""); } } }
boolean cacheEnabled = facesContext.isProjectStage(ProjectStage.Production); Map<Class<?>, Map<String, Object>> cache = PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance()).getEnumCacheMap();
public AjaxRequestBuilder form(AjaxSource source, UIComponent component, UIForm formComponent) { String result = null; String form = source.getForm(); if (LangUtils.isValueBlank(form)) { if (formComponent == null) { formComponent = ComponentTraversalUtils.closestForm(context, component); } if (formComponent == null) { if (context.isProjectStage(ProjectStage.Development)) { String message = "Component '" + component.getClientId(context) + "' should be inside a form or should reference a form via its form attribute." + " We will try to find a fallback form on the client side."; LOG.info(message); } } else { result = formComponent.getClientId(context); } } else { result = SearchExpressionFacade.resolveClientId(context, component, source.getForm()); } if (result != null) { buffer.append(",f:\"").append(result).append("\""); } return this; }
String expression, char separatorChar) { if (context.isProjectStage(ProjectStage.Development)) {
/** * Constructor. * * @param context the Faces context. */ public JspStateManagementStrategy(FacesContext context) { isDevelopmentMode = context.isProjectStage(ProjectStage.Development); classMap = new ConcurrentHashMap<>(32); }
/** * @since JSF 2.0 */ @Override public boolean isProjectStage(ProjectStage stage) { return FacesContext.getCurrentInstance().isProjectStage(stage); }
public I18nMapCompat() { FacesContext facesContext = FacesContext.getCurrentInstance(); if (facesContext == null) { this.cacheEnabled = true; } else { this.cacheEnabled = !facesContext.isProjectStage(ProjectStage.Development); } }
/** * <p>The default behavior of this method is to * call {@link javax.faces.context.FacesContext#isProjectStage(javax.faces.application.ProjectStage)} * on the wrapped {@link FacesContext} object.</p> * * @see FacesContext#isProjectStage(javax.faces.application.ProjectStage) */ @Override public boolean isProjectStage(ProjectStage stage) { return getWrapped().isProjectStage(stage); } }
@Override public boolean isProjectStage(ProjectStage stage) { return getWrapped().isProjectStage(stage); }
/** * <p>The default behavior of this method is to * call {@link javax.faces.context.FacesContext#isProjectStage(javax.faces.application.ProjectStage)} * on the wrapped {@link FacesContext} object.</p> * * @see FacesContext#isProjectStage(javax.faces.application.ProjectStage) */ @Override public boolean isProjectStage(ProjectStage stage) { return getWrapped().isProjectStage(stage); } }
PropertyHandler getHandler(FaceletContext ctx, String name) { if (!ctx.getFacesContext().isProjectStage(ProjectStage.Development)) { if (Arrays.binarySearch(DEV_ONLY_ATTRIBUTES, name) >= 0) { return null; } } PropertyHandler h = managedHandlers.get(name); return ((h != null) ? h : genericHandler); }
/** * <p>The default behavior of this method is to * call {@link javax.faces.context.FacesContext#isProjectStage(javax.faces.application.ProjectStage)} * on the wrapped {@link FacesContext} object.</p> * * @see FacesContext#isProjectStage(javax.faces.application.ProjectStage) */ @Override public boolean isProjectStage(ProjectStage stage) { return getWrapped().isProjectStage(stage); } }
private void _handleAnnotations(FacesContext context, Object inspected, UIComponent component) { // determine the ProjectStage setting via the given FacesContext // note that a local getProjectStage() could cause problems in wrapped environments boolean isProduction = context.isProjectStage(ProjectStage.Production); Class<?> inspectedClass = inspected.getClass(); _handleListenerForAnnotations(context, inspected, inspectedClass, component, isProduction); _handleResourceDependencyAnnotations(context, inspectedClass, component, isProduction); }
protected static void validateRenderer(FacesContext context, UIComponent source, UIComponent component, String expression, int hints) { if (SearchExpressionUtils.isHintSet(hints, SearchExpressionHint.VALIDATE_RENDERER) && context.isProjectStage(ProjectStage.Development)) { if (ComponentUtils.isValueBlank(component.getRendererType())) { LOG.warning("Can not update component \"" + component.getClass().getName() + "\" with id \"" + component.getClientId(context) + "\" without a attached renderer. Expression \"" + expression + "\" referenced from \"" + source.getClientId(context) + "\""); } } }
public void write(FacesContext context) throws IOException { // render all unhandled FacesMessages when ProjectStage is Development if (context.isProjectStage(ProjectStage.Development)) { HtmlRendererUtils.renderUnhandledFacesMessages(context); } context.getResponseWriter().endElement(this.element); }
public void setSubmittedValue(Object submittedValue) { FacesContext facesContext = getFacesContext(); if (facesContext != null && facesContext.isProjectStage(ProjectStage.Development)) { // extended debug-info when in Development mode _createFieldDebugInfo(facesContext, "submittedValue", getStateHelper().get(PropertyKeys.submittedValue), submittedValue, 1); } getStateHelper().put(PropertyKeys.submittedValue, submittedValue ); }