public <T> T eval(String attr, T unspecifiedValue) { if (literals.containsKey(attr)) { Object val = literals.get(attr); if (val == null) { return unspecifiedValue; } else { return (T) val; } } ValueExpression ve = bindings.get(attr); if (ve != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); return (T) ve.getValue(elContext); } return unspecifiedValue; }
public Integer getSize() { if (size != null) { return size; } ValueExpression ve = getValueExpression("size"); if (ve != null) { return (Integer) ve.getValue(getFacesContext().getELContext()); } return null; }
public int compare(Object obj1, Object obj2) { try { FacesContext context = FacesContext.getCurrentInstance(); Object value1 = sortBy.getValue(context.getELContext()); context.getExternalContext().getRequestMap().put(var, obj2); Object value2 = sortBy.getValue(context.getELContext()); result = (Integer) sortFunction.invoke(context.getELContext(), new Object[]{value1, value2}); throw new FacesException(e);
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); } }
@Override public String getEventName() { if (event == null) { return null; } if (event.isLiteral()) { return event.getValue(); } else { FaceletContext faceletContext = getFaceletContext(FacesContext.getCurrentInstance()); ValueExpression expression = event.getValueExpression(faceletContext, String.class); return (String) expression.getValue(faceletContext); } }
@SuppressWarnings("unchecked") public static <T> T getValue(ValueExpression valueExpression, Class<T> expectedType) { try { return (T) valueExpression.getValue(getELContext()); } catch (ELException e) { throw new FacesException(e); } }
@Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { if (value == null) { throw new AbortProcessingException("Value has not been set"); } ELContext elContext = FacesContext.getCurrentInstance().getELContext(); Object val = value.getValue(elContext); if (addTo != null) { Collection collection = (Collection) addTo.getValue(elContext); Object uniqueValue = (unique != null) ? unique.getValue(elContext) : null; boolean checkUniqueness = (uniqueValue == null) ? true : Boolean.parseBoolean(uniqueValue.toString()); if (checkUniqueness) { if (!collection.contains(val)) { collection.add(val); } } else { collection.add(val); } } else if (removeFrom != null) { Collection collection = (Collection) removeFrom.getValue(elContext); collection.remove(val); } else { throw new IllegalArgumentException("Specify either addTo or removeFrom as collection reference"); } }
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; } }
String tables = (String) target.getValue(elContext); String exportAs = (String) type.getValue(elContext); String outputFileName = (String) fileName.getValue(elContext); encodingType = (String) encoding.getValue(elContext); if (repeat != null) { repeating = repeat.isLiteralText() ? Boolean.parseBoolean(repeat.getValue(context.getELContext()).toString()) : (Boolean) repeat.getValue(context.getELContext()); if (pageOnly != null) { isPageOnly = pageOnly.isLiteralText() ? Boolean.parseBoolean(pageOnly.getValue(context.getELContext()).toString()) : (Boolean) pageOnly.getValue(context.getELContext()); if (selectionOnly != null) { 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);
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); } }
@Override public Object invoke(ELContext elContext, Object[] args) { Util.notNull("elContext", elContext); Object result = lookupExpression.getValue(elContext); if (result == null) { throw new FacesException("Unable to resolve composite component from using page using EL expression '" + lookupExpression.getExpressionString() + '\''); } if (!(result instanceof MethodExpression)) { throw new FacesException("Successfully resolved expression '" + lookupExpression.getExpressionString() + "', but the value is not a MethodExpression"); } return ((MethodExpression) result).invoke(elContext, args); }
@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); } } }
public Integer getEnd() { if (end != null) { return end; } ValueExpression ve = getValueExpression("end"); if (ve != null) { return (Integer) ve.getValue(getFacesContext().getELContext()); } return null; }
public int compare(Object obj1, Object obj2) { try { FacesContext context = FacesContext.getCurrentInstance(); Object value1 = sortBy.getValue(context.getELContext()); context.getExternalContext().getRequestMap().put(var, ((TreeNode) obj2).getData()); Object value2 = sortBy.getValue(context.getELContext()); result = (Integer) sortFunction.invoke(context.getELContext(), new Object[]{value1, value2}); throw new FacesException(e);
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 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); }
public String getName() { if (_name != null) { return (String) _name.getValue(FacesContext.getCurrentInstance().getELContext()); } return null; }
public Integer getOffset() { if (begin != null) { return begin; } ValueExpression ve = getValueExpression("offset"); if (ve != null) { return (Integer) ve.getValue(getFacesContext().getELContext()); } return null; }
@Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); StreamedContent content = (StreamedContent) value.getValue(elContext); String contentDispositionValue = contentDisposition != null ? (String) contentDisposition.getValue(elContext) : "attachment"; String monitorKeyValue = monitorKey != null ? "_" + (String) monitorKey.getValue(elContext) : ""; throw new FacesException(e);
public String getEvent() { if (_event != null) { return (String) _event.getValue(FacesContext.getCurrentInstance().getELContext()); } return null; }