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()); throw new FacesException(e);
public void updatePaginationData(FacesContext context) { String componentClientId = getClientId(context); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ELContext elContext = context.getELContext(); String firstParam = params.get(componentClientId + "_first"); String rowsParam = params.get(componentClientId + "_rows"); setFirst(Integer.valueOf(firstParam)); setRows(Integer.valueOf(rowsParam)); ValueExpression firstVe = getValueExpression("first"); ValueExpression rowsVe = getValueExpression("rows"); if (firstVe != null && !firstVe.isReadOnly(elContext)) { firstVe.setValue(context.getELContext(), getFirst()); } if (rowsVe != null && !rowsVe.isReadOnly(elContext)) { rowsVe.setValue(context.getELContext(), getRows()); } }
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); }
@Override public void processAction(ActionEvent event) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); VisitContext visitContext = VisitContext.createVisitContext(context, null, ComponentUtils.VISIT_HINTS_SKIP_UNRENDERED); String expressions = (String) target.getValue(elContext); boolean resetModel = false; if (clearModel != null) { resetModel = clearModel.isLiteralText() ? Boolean.parseBoolean(clearModel.getValue(context.getELContext()).toString()) : (Boolean) clearModel.getValue(context.getELContext()); } ResetInputVisitCallback visitCallback = resetModel ? ResetInputVisitCallback.INSTANCE_CLEAR_MODEL : ResetInputVisitCallback.INSTANCE; List<UIComponent> components = SearchExpressionFacade.resolveComponents(context, event.getComponent(), expressions); for (int i = 0; i < components.size(); i++) { UIComponent component = components.get(i); component.visitTree(visitContext, visitCallback); } } }
@Override public void processAction(ActionEvent event) { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); String tables = (String) target.getValue(elContext); String exportAs = (String) type.getValue(elContext); String outputFileName = (String) fileName.getValue(elContext); encodingType = (String) encoding.getValue(elContext); repeating = repeat.isLiteralText() ? Boolean.parseBoolean(repeat.getValue(context.getELContext()).toString()) : (Boolean) repeat.getValue(context.getELContext()); isPageOnly = pageOnly.isLiteralText() ? Boolean.parseBoolean(pageOnly.getValue(context.getELContext()).toString()) : (Boolean) pageOnly.getValue(context.getELContext()); isSelectionOnly = selectionOnly.isLiteralText() ? Boolean.parseBoolean(selectionOnly.getValue(context.getELContext()).toString()) : (Boolean) selectionOnly.getValue(context.getELContext()); exporterOptions = (ExporterOptions) options.getValue(elContext); customExporterInstance = (Object) customExporter.getValue(elContext); throw new FacesException(e);
@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()); }
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; } }
public void setValue(final FacesContext context, final String expression, final Object value) throws ELException { ExpressionFactory ef = context.getApplication().getExpressionFactory(); ValueExpression ve = ef.createValueExpression(context.getELContext(), expression, Object.class); ve.setValue(context.getELContext(), ef.coerceToType(value, ve.getType(context.getELContext()))); }
public static void setConverter(ValueHolder valueHolder, Object converterExpression) { if (converterExpression instanceof ValueExpression) { ValueExpression expression = (ValueExpression) converterExpression; if (!expression.isLiteralText()) { ((UIComponent) valueHolder).setValueExpression("converter", expression); } else { valueHolder.setConverter(FacesContext.getCurrentInstance() .getApplication().createConverter(expression.getExpressionString())); } } }
@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);
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; }
protected Class<? extends SystemEvent> getEventClass(FaceletContext ctx) { String eventType = (String) this.type.getValueExpression(ctx, String.class).getValue(ctx); if (eventType == null) { throw new FacesException("Attribute 'type' can not be null"); } return ApplicationAssociate.getInstance(ctx.getFacesContext().getExternalContext()) .getNamedEventManager().getNamedEvent(eventType); }
/** * {@inheritDoc} */ @Override public String resolve(String expression) { ValueExpression expr = expressionFactory.createValueExpression(elContext, expression, String.class); return String.valueOf(expr.getValue(elContext)); } }
public void processAction(ActionEvent evt) throws AbortProcessingException { FacesContext faces = FacesContext.getCurrentInstance(); ELContext el = faces.getELContext(); Object valueObj = this.value.getValue(el); if (valueObj != null) { ExpressionFactory factory = faces.getApplication().getExpressionFactory(); valueObj = factory.coerceToType(valueObj, target.getType(el)); } this.target.setValue(el, valueObj); }
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;
public void setLiteralValue(String name, ValueExpression expression) { assert (expression.isLiteralText()); ELContext context = getFacesContext().getELContext(); try { setLiteralAttribute(name, expression.getValue(context)); } catch (ELException elem) { throw new FacesException(elem); } }
protected String resolveTheme(FacesContext context) { String theme = null; String themeConfigValue = RequestContext.getCurrentInstance(context).getApplicationContext().getConfig().getMobileTheme(); if (themeConfigValue != null) { ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression ve = expressionFactory.createValueExpression(elContext, themeConfigValue, String.class); theme = ve.isLiteralText() ? themeConfigValue : (String) ve.getValue(elContext); } return theme; }
public Integer getSize() { if (size != null) { return size; } ValueExpression ve = getValueExpression("size"); if (ve != null) { return (Integer) ve.getValue(getFacesContext().getELContext()); } return null; }
@Override protected UIComponent getPopup(ActionEvent actionEvent) { String id = (String) popupIdExpression.getValue(FacesContext.getCurrentInstance().getELContext()); UIComponent popup = FindComponentUtils.findComponent(actionEvent.getComponent(), id); if (popup == null) { LOG.error("Found no popup for \"" + popupIdExpression.getExpressionString() + "\" := \"" + id + "\"! Search base componentId : " + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance())); } return popup; }
@Override public void processUpdates(FacesContext context) { if (isValueChanged()) { ValueExpression ve = getValueExpression("value"); ELContext elc = FacesContext.getCurrentInstance().getELContext(); if (ve != null && !ve.isReadOnly(elc)) { ve.setValue(elc, isExpanded()); } } super.processUpdates(context); } }