@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); Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap(); NavigationCase navCase = getNavigationCase(context, fromAction, dialogOutcome); String toViewId = navCase.getToViewId(context); String url = context.getApplication().getViewHandler().getBookmarkableURL(context, toViewId, params, includeViewParams); url = EscapeUtils.forJavaScript(url);
public boolean isRTL() { if (rtl == null) { String param = context.getExternalContext().getInitParameter(Constants.ContextParams.DIRECTION); if (param == null) { rtl = false; } else { ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression expression = expressionFactory.createValueExpression(elContext, param, String.class); String expressionValue = (String) expression.getValue(elContext); rtl = (expressionValue == null) ? false : expressionValue.equalsIgnoreCase("rtl"); } } return rtl; } }
protected Converter findImplicitConverter(FacesContext context, UIComponent component) { ValueExpression ve = component.getValueExpression("value"); if (ve != null) { Class<?> valueType = ve.getType(context.getELContext()); if (valueType != null) { if (valueType.isArray()) { valueType = valueType.getComponentType(); } return context.getApplication().createConverter(valueType); } } return null; }
public static void addComponentResource(FacesContext context, String name, String library, String target) { Application application = context.getApplication(); UIComponent componentResource = application.createComponent(UIOutput.COMPONENT_TYPE); componentResource.setRendererType(application.getResourceHandler().getRendererTypeForResourceName(name)); componentResource.getAttributes().put("name", name); componentResource.getAttributes().put("library", library); componentResource.getAttributes().put("target", target); context.getViewRoot().addComponentResource(context, componentResource, target); }
if (event instanceof MenuActionEvent) { FacesContext facesContext = getFacesContext(); ELContext eLContext = facesContext.getELContext(); MenuActionEvent menuActionEvent = (MenuActionEvent) event; MenuItem menuItem = menuActionEvent.getMenuItem(); MethodExpression noArgExpr = facesContext.getApplication().getExpressionFactory(). createMethodExpression(eLContext, actionExpressionString, String.class, new Class[0]); Object invokeResult = null; MethodExpression argExpr = facesContext.getApplication().getExpressionFactory(). createMethodExpression(eLContext, actionExpressionString, String.class, new Class[]{ActionEvent.class}); MethodExpression argExpr = facesContext.getApplication().getExpressionFactory(). createMethodExpression(eLContext, actionExpressionString, String.class, new Class[]{MenuActionEvent.class}); String outcome = (invokeResult != null) ? invokeResult.toString() : null; facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, actionExpressionString, outcome);
@Override public String getDetail() { FacesContext facesContext = FacesContext.getCurrentInstance(); ValueExpression value = facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), super.getDetail(), String.class); return (String)value.getValue(facesContext.getELContext()); }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(context); ProjectStage projectStage = context.getApplication().getProjectStage(); boolean csvEnabled = applicationContext.getConfig().isClientSideValidationEnabled(); writer.writeAttribute("id", component.getClientId(context), "id"); UIComponent first = component.getFacet("first"); if (first != null) { first.encodeAll(context); ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression ve = expressionFactory.createValueExpression(elContext, themeParamValue, String.class); theme = (String) ve.getValue(elContext); UIViewRoot viewRoot = context.getViewRoot(); List<UIComponent> resources = viewRoot.getComponentResources(context, "head"); for (int i = 0; i < resources.size(); i++) { UIComponent resource = resources.get(i); writer.write("if(window.PrimeFaces){"); writer.write("PrimeFaces.settings.locale='" + context.getViewRoot().getLocale() + "';");
public String resolveDynamicField(ValueExpression expression) { if (expression == null) { return null; } FacesContext context = getFacesContext(); ELContext elContext = context.getELContext(); String expressionString = expression.getExpressionString(); // old syntax compatibility // #{car[column.property]} // new syntax is: // #{column.property} or even a method call if (expressionString.startsWith("#{" + getVar() + "[")) { expressionString = expressionString.substring(expressionString.indexOf("[") + 1, expressionString.indexOf("]")); expressionString = "#{" + expressionString + "}"; ValueExpression dynaVE = context.getApplication() .getExpressionFactory().createValueExpression(elContext, expressionString, String.class); return (String) dynaVE.getValue(elContext); } return (String) expression.getValue(elContext); }
public static NavigationCase findNavigationCase(FacesContext context, String outcome) { ConfigurableNavigationHandler navHandler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler(); String outcomeValue = (outcome == null) ? context.getViewRoot().getViewId() : outcome; return navHandler.getNavigationCase(context, null, outcomeValue); }
/** * Set a ValueBinding on a component - used by tags setProperties() method. */ public static void setValueBinding(UIComponent component, String name, String value) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(value); component.setValueBinding(name, vb); }
/** * @param facesContext * @return String A String representing the action URL */ public String getActionUrl(FacesContext facesContext) { ViewHandler viewHandler = facesContext.getApplication().getViewHandler(); String viewId = facesContext.getViewRoot().getViewId(); return viewHandler.getActionURL(facesContext, viewId); }
Resource resource = context.getApplication().getResourceHandler().createResource( "dynamiccontent.properties", "primefaces", streamedContent.getContentType()); String resourcePath = resource.getRequestPath(); Map<String, Object> session = context.getExternalContext().getSessionMap(); Map<String, String> dynamicResourcesMapping = (Map) session.get(Constants.DYNAMIC_RESOURCES_MAPPING); if (dynamicResourcesMapping == null) { context.getELContext(), component.getValueExpression("value")); String expressionString = expression.getExpressionString(); String resourceKey = md5(expressionString); .append("&").append(Constants.DYNAMIC_CONTENT_TYPE_PARAM).append("=").append(type.toString()); for (int i = 0; i < component.getChildCount(); i++) { UIComponent child = component.getChildren().get(i); if (child instanceof UIParameter) { UIParameter param = (UIParameter) child;
@Override public void recreateComponentTree(FacesContext facesContext) { Application application = facesContext.getApplication(); ViewHandler viewHandler = application.getViewHandler(); UIViewRoot oldViewRoot = facesContext.getViewRoot(); UIViewRoot viewRoot = viewHandler.createView(facesContext, oldViewRoot.getViewId()); facesContext.setViewRoot(viewRoot); facesContext.renderResponse(); }
/** * @deprecated since 2.0.0 */ @Deprecated public static void setStateChangeListenerMethodBinding( final UIComponent component, final String value, final Class[] args) { if (value != null && UIComponentTag.isValueReference(value)) { final MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication() .createMethodBinding(value, args); ((SheetStateChangeSource) component).setStateChangeListener(methodBinding); } }
public static void includeCompositeComponent(UIComponent parent, String taglibURI, String tagName, String id) { FacesContext context = FacesContext.getCurrentInstance(); UIComponent composite = context.getApplication().getViewHandler() .getViewDeclarationLanguage(context, context.getViewRoot().getViewId()) .createComponent(context, taglibURI, tagName, null); composite.setId(id); parent.getChildren().add(composite); }
@Override protected Validator createValidator() { FacesContext ctx = FacesContext.getCurrentInstance(); Application app = ctx.getApplication(); RegexValidator validator = (RegexValidator) app.createValidator("com.sun.faces.ext.validator.RegexValidator"); validator.setPattern((String) regex.getValue(ctx.getELContext())); return validator; } }
protected static String translate(FacesContext context, String label) { String bundleName = context.getApplication().getMessageBundle(); Locale locale = context.getViewRoot().getLocale(); label = I18NUtils.getMessageString(bundleName, label, null, locale); return label; }
public static String getResourceURL(FacesContext context, String value) { if (LangUtils.isValueBlank(value)) { return Constants.EMPTY_STRING; } else if (value.contains(ResourceHandler.RESOURCE_IDENTIFIER)) { return value; } else { String url = context.getApplication().getViewHandler().getResourceURL(context, value); return context.getExternalContext().encodeResourceURL(url); } }
public static void includeCompositeComponent(UIComponent parent, String libraryName, String resourceName, String id) { // Prepare. FacesContext context = FacesContext.getCurrentInstance(); Application application = context.getApplication(); FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); // This basically creates <ui:component> based on <composite:interface>. Resource resource = application.getResourceHandler().createResource(resourceName, libraryName); UIComponent composite = application.createComponent(context, resource); composite.setId(id); // Mandatory for the case composite is part of UIForm! Otherwise JSF can't find inputs. // This basically creates <composite:implementation>. UIComponent implementation = application.createComponent(UIPanel.COMPONENT_TYPE); implementation.setRendererType("javax.faces.Group"); composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, implementation); // Now include the composite component file in the given parent. parent.getChildren().add(composite); parent.pushComponentToEL(context, composite); // This makes #{cc} available. try { faceletContext.includeFacelet(implementation, resource.getURL()); } catch (IOException e) { throw new FacesException(e); } finally { parent.popComponentFromEL(context); } }
return getFacesContext().getViewRoot(); return getFacesContext().getViewRoot().getViewMap(); return getFacesContext().getApplication().getResourceHandler();