@Override public void processAction(ActionEvent evt) throws AbortProcessingException { FacesContext faces = FacesContext.getCurrentInstance(); Object valueObj = this.value.getValue(faces); this.target.setValue(faces, valueObj); }
public String getExpressionString() { assert(null != binding); return binding.getExpressionString(); }
public Class<?> invoke() { return getNotNullValueBinding().getType(getFacesContext(context)); } });
private Object getValue() { if (UIComponentTag.isValueReference(_value)) { FacesContext facesContext = FacesContext.getCurrentInstance(); ValueBinding vb = facesContext.getApplication().createValueBinding(_value); return vb.getValue(facesContext); } return _value; }
public boolean equals(Object other) { if (other == this) { return true; } if (other instanceof ValueBindingValueExpressionAdapter) { ValueExpression expr = ((ValueBindingValueExpressionAdapter) other).getWrapped(); return (valueExpression.equals(expr)); } else if (other instanceof ValueBinding) { FacesContext context = FacesContext.getCurrentInstance(); ValueBinding otherVB = (ValueBinding) other; Class type = otherVB.getType(context); if (type != null) { return type.equals(valueExpression.getType(context.getELContext())); } } return false; }
protected Converter findUIOutputConverter(FacesContext facesContext, UIComponent component) { Converter converter = ((EditableValueHolder)component).getConverter(); if (converter != null) return converter; //Try to find out by value binding ValueBinding vb = component.getValueBinding("value"); if (vb == null) return null; Class valueType = vb.getType(facesContext); if (valueType == null) return null; if (String.class.equals(valueType)) return null; //No converter needed for String type if (Object.class.equals(valueType)) return null; //There is no converter for Object class try { return facesContext.getApplication().createConverter(valueType); } catch (FacesException e) { getFacesContext().getExternalContext().log("No Converter for type " + valueType.getName() + " found", e); return null; } }
public static String getClassName(UIComponent uiComponent, String styleClass, String styleClassAsString, String defaultStyleClass) { if (styleClass != null) { return styleClass; } ValueBinding vb = uiComponent.getValueBinding(styleClassAsString); return vb != null ? (String) vb.getValue(FacesContext.getCurrentInstance()) : defaultStyleClass; }
@Override protected UIComponent getPopup(ActionEvent actionEvent) { String id = (String) popupIdBinding.getValue(FacesContext.getCurrentInstance()); UIComponent popup = FindComponentUtils.findComponent(actionEvent.getComponent(), id); if (popup == null) { LOG.error("Found no popup for \"" + popupIdBinding.getExpressionString() + "\" := \"" + id + "\"! Search base componentId : " + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance())); } return popup; }
private boolean updateValueBoundObject(FacesContext context, String valueBinding, String value) { try { ValueBinding vb = context.getApplication().createValueBinding(valueBinding); vb.setValue(context, value); } catch (EvaluationException ex) { return false; } return true; }
@Override public void decode(FacesContext facesContext, UIComponent uiComponent) { super.decode(facesContext, uiComponent); String scrollPositionParameter = uiComponent.getClientId(facesContext) + SCROLL_POSITION_SUFFIX; String scrollPosition = facesContext.getExternalContext().getRequestParameterMap().get(scrollPositionParameter); if (scrollPosition != null) { ValueBinding vb = uiComponent.getValueBinding("scrollPosition"); if (vb != null) { vb.setValue(facesContext, scrollPosition); } } }
private void computeEvaluatedExpression(FacesContext facesContext){ if( evaluatedExpression != null ) return; ValueBinding valueVB = null; if (_valueExpression == null) { valueVB = _aliasComponent.getValueBinding("value"); _valueExpression = valueVB.getExpressionString(); } if( valueVB == null ){ if( _valueExpression.startsWith("#{") ){ valueVB = facesContext.getApplication().createValueBinding(_valueExpression); evaluatedExpression = valueVB.getValue(facesContext); }else{ evaluatedExpression = _valueExpression; } }else{ evaluatedExpression = valueVB.getValue(facesContext); } }
/** * Activate this alias (ie create the temporary name). */ void make(FacesContext facesContext){ if( _active ) return; ValueBinding aliasVB; if (_aliasBeanExpression == null) { aliasVB = _aliasComponent.getValueBinding("alias"); if( aliasVB == null ) return; _aliasBeanExpression = aliasVB.getExpressionString(); if( _aliasBeanExpression == null ) return; } else { aliasVB = facesContext.getApplication().createValueBinding(_aliasBeanExpression); } computeEvaluatedExpression( facesContext ); aliasVB.setValue(facesContext, evaluatedExpression); _active = true; log.debug("makeAlias: " + _valueExpression + " = " + _aliasBeanExpression); }
/** * @deprecated since 2.0.0 */ @Deprecated public static String getValueFromEl(String script) { if (UIComponentTag.isValueReference(script)) { final ValueBinding valueBinding = createValueBinding(script); script = (String) valueBinding.getValue(FacesContext.getCurrentInstance()); } return script; } }
public void setValue(final FacesContext context, final String expression, final Object value) throws ELException { ValueBinding valueBinding = context.getApplication().createValueBinding(expression); Class<?> type = valueBinding.getType(context); Converter converter = ConvertUtils.lookup(type); if (converter == null) { throw new UnsupportedOperationException("Cant deal with " + type); } valueBinding.setValue(context, converter.convert(type, value)); }
public static Object getValueFromCreatedValueBinding(String buindName) { FacesContext context = getFacesContext(); ValueBinding vb = context.getApplication() .createValueBinding(buindName); return vb.getValue(context); }
public Class<?> getExpectedType(final FacesContext context, final String expression) throws ELException { ValueBinding valueBinding = context.getApplication().createValueBinding(expression); return valueBinding.getType(context); } }
protected String[] getValuesForRender(FacesContext context, UIComponent component) { final ExternalContext externalContext = context.getExternalContext(); final Map requestMap = externalContext.getRequestMap(); String value = ValueHolderUtil.getValueForRender(context, component); if (PostbackUtil.isPostback(requestMap)) { return new String[] { value }; } else { final ValueBinding vb = component.getValueBinding("value"); if (vb == null) { return null; } Class type = vb.getType(context); if (type.isPrimitive() && value.equals("0")) { return null; } return new String[] { value }; } }
public static Object getValueBindingValue(UIComponent component, String bindingName) { ValueBinding vb = component.getValueBinding(bindingName); return (vb != null) ? vb.getValue(component.getFacesContext()) : null; }
public static String getExpressionString(UIComponent component, String name) { if (USE_BINDING) { return component.getValueBinding(name).getExpressionString(); } else { return FacesUtilsEL.getExpressionString(component, name); } }
public static Object getValueFromValueBindingOrValueExpression( FacesContext context, UIComponent component, String name) { if (USE_BINDING) { return component.getValueBinding(name).getValue(context); } else { return FacesUtilsEL.getValueFromValueBindingOrValueExpression(context, component, name); } }