Java Code Examples for javax.faces.el.ValueBinding

The following are top voted examples for showing how to use javax.faces.el.ValueBinding. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myfaces-trinidad   File: PeriodicDialogBean.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public String select()
{
  FacesContext context = FacesContext.getCurrentInstance();
  // The tableSelectOne is marked as required; so there'd better
  // be a selected row - an exception will result here if there
  // isn't.  Is there some better code?
  Iterator<Object> iterator = _table.getSelectedRowKeys().iterator();
  Object rowKey = iterator.next();
  Object oldRowKey = _table.getRowKey();
  _table.setRowKey(rowKey);
  ValueBinding binding = context.getApplication().
    createValueBinding("#{row.symbol}");
  Object value = binding.getValue(context);
  RequestContext.getCurrentInstance().returnFromDialog(value, null);
  _table.setRowKey(oldRowKey);

  return null;
}
 
Example 2
Project: myfaces-trinidad   File: InputListOfValuesBean.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public String select() {
    try{
    FacesContext context = FacesContext.getCurrentInstance();
    Iterator<Object> iterator = _table.getSelectedRowKeys().iterator();
    Object rowKey = iterator.next();
    Object oldRowKey = _table.getRowKey();
    _table.setRowKey(rowKey);
    ValueBinding binding = context.getApplication().
            createValueBinding("#{row.name}");
    Object value = binding.getValue(context);
    RequestContext.getCurrentInstance().returnFromDialog(value, null);
    _table.setRowKey(oldRowKey);
    }
    catch (NoSuchElementException e){}

    return null;
}
 
Example 3
Project: myfaces-trinidad   File: LabeledFacesMessage.java   View source code 6 votes vote down vote up
/**
 * Gets a string representation of the label.  If the label
 * is a ValueBinding, the expression is evaluated and the string
 * value returned.
 */
public String getLabelAsString(FacesContext context)
{
  Object label = getLabel();

  if (label instanceof ValueExpression)
  {
    label = ((ValueExpression) label).getValue(context.getELContext());          
  }
  else if (label instanceof ValueBinding)
  {
    label = ((ValueBinding) label).getValue(context);
  }

  if (label == null)
    return null;

  return label.toString();
}
 
Example 4
Project: myfaces-trinidad   File: UIXComponentBase.java   View source code 6 votes vote down vote up
/**
 */
@Override
public ValueBinding getValueBinding(String name)
{
  if (name == null)
    throw new NullPointerException();

  PropertyKey key = getPropertyKey(name);

  // Support standard RI behavior where getValueBinding()
  // doesn't complain about being asked for a ValueBinding -
  // but continue supporting strict behavior at FacesBean layer.
  if (!key.getSupportsBinding())
    return null;

  return getFacesBean().getValueBinding(key);
}
 
Example 5
Project: myfaces-trinidad   File: ValueExpressionValueBinding.java   View source code 6 votes vote down vote up
/**
 * Given a ValueExpression <code>ve</code>, return a ValueBinding.
 * The returned ValueBinding will implement StateHolder and Serializable interfaces if
 * <code>ve</code> implements these interfaces.
 * @param ve  The ValueExpression
 * @return a ValueBinding equivalent to the ValueExpression
 */
public static ValueBinding getValueBinding(ValueExpression ve)
{
  // if we previously wrapped a ValueBinding, unwrap it and return it, otherwise create the
  // correct subclass of ValueBinding
  if (ve instanceof ValueBindingValueExpression)
    return ((ValueBindingValueExpression)ve).getValueBinding();
  else if (ve instanceof StateHolder)
  {
    if (ve instanceof Serializable)
      return new SerializableStateHolderValueExpressionValueBinding(ve);
    else
      return new StateHolderValueExpressionValueBinding(ve);      
  }
  else if (ve instanceof Serializable)
  {
    return new SerializableValueExpressionValueBinding(ve);
  }
  else
  {
    return new ValueExpressionValueBinding(ve);      
  }    
}
 
Example 6
Project: myfaces-trinidad   File: ValueBindingValueExpression.java   View source code 6 votes vote down vote up
/**
 * Given a ValueBinding <code>binding</code>, return a ValueExpression.
 * The returned ValueExpression will implement StateHolder and Serializable interfaces if
 * <code>ve</code> implements these interfaces.
 * @param binding  The ValueBinding
 * @return a ValueExpression equivalent to the ValueBinding
 */
public static ValueExpression getValueExpression(ValueBinding binding)
{
  // if we previously wrapped a ValueExpression, unwrap it and return it, otherwise create the
  // correct subclass of ValueBindingValueExpression
  if (binding instanceof ValueExpressionValueBinding)
    return ((ValueExpressionValueBinding)binding).getValueExpression();
  else if (binding instanceof StateHolder)
  {
    if (binding instanceof Serializable)
      return new SerializableStateHolderValueBindingValueExpression(binding);
    else
      return new StateHolderValueBindingValueExpression(binding);      
  }
  else if (binding instanceof Serializable)
  {
    return new SerializableValueBindingValueExpression(binding);
  }
  else
  {
    return new ValueBindingValueExpression(binding);      
  }
}
 
Example 7
Project: myfaces-trinidad   File: FacesBeanImpl.java   View source code 6 votes vote down vote up
@SuppressWarnings("deprecation")
final public void setValueBinding(PropertyKey key, ValueBinding binding)
{
  ValueExpression ve;

  if (binding == null)
  {
    ve = null;
  }
  else
  {
    ve = ValueBindingValueExpression.getValueExpression(binding);
  }

  setValueExpression(key, ve);
}
 
Example 8
Project: myfaces-trinidad   File: AttributeComponentChange.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("deprecation")
public void changeComponent(UIComponent uiComponent)
{
  Map<String, Object> attributeMap = uiComponent.getAttributes();

  // if the attributevalue is a ValueExpression or ValueBinding, use the
  // appropriate setValueExpression/setValueBinding call and remove the
  // current attribute value, if any, so that the ValueExpression/ValueBinding
  // can take precedence
  if (_attributeValue instanceof ValueExpression)
  {
    uiComponent.setValueExpression(_attributeName, (ValueExpression)_attributeValue);
    attributeMap.remove(_attributeName);
  }
  else if (_attributeValue instanceof ValueBinding)
  {
    uiComponent.setValueBinding(_attributeName, (ValueBinding)_attributeValue);
    attributeMap.remove(_attributeName);
  }
  else
  {
    attributeMap.put(_attributeName, _attributeValue);
  }
}
 
Example 9
Project: myfaces-trinidad   File: UIXInputTest.java   View source code 6 votes vote down vote up
/**
 * Tests to make sure the setValue(), isLocalValueSet() contract is
 * preserved.
 */
public void testLocalValue()
{
  UIXInput input = new UIXInput();
  assertFalse(input.isLocalValueSet());
  assertNull(input.getLocalValue());
  assertNull(input.getValue());
  
  // setup a valueBinding
  Mock mockBinding = mock(ValueBinding.class);
  ValueBinding binding = (ValueBinding) mockBinding.proxy();
  mockBinding.expects(atLeastOnce()).method("getValue").will(returnValue(Boolean.TRUE));//  setupGetValue(Boolean.TRUE);
  
  input.setValueBinding("value", binding);
  assertFalse(input.isLocalValueSet());
  assertNull(input.getLocalValue());
  assertEquals(Boolean.TRUE, input.getValue());
  
  // now set a local value
  input.setValue("foo");
  assertTrue(input.isLocalValueSet());
  assertEquals("foo", input.getLocalValue());
  assertEquals("foo", input.getValue());
}
 
Example 10
Project: sakai   File: TocTreeTag.java   View source code 6 votes vote down vote up
/** 
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component)
{
  super.setProperties(component);
  FacesContext context = getFacesContext();
  if (value != null)
  {
    ValueBinding vb = context.getApplication().createValueBinding(value);
    component.setValueBinding("value", vb);
  }
  if (var != null)
  {
    ((UIData) component).setVar(var);
  }

}
 
Example 11
Project: sakai   File: RendererUtil.java   View source code 6 votes vote down vote up
/**
 * Sets component attribute value - if a ValueBinding exists for that
 * attribute, set through the binding; otherwise, set the value directly on
 * the component.
 */
public static void setAttribute(FacesContext context, UIComponent component, String name,
        Object value)
{
    ValueBinding binding = component.getValueBinding(name);
    if (binding != null)
    {
        try
        {
            binding.setValue(context, value);
        } catch (IllegalArgumentException e)
        {
            // try setting the value as a String
            binding.setValue(context, String.valueOf(value));
        }
    } else
    {
        component.getAttributes().put(name, value);
    }
}
 
Example 12
Project: sakai   File: RichTextEditArea.java   View source code 6 votes vote down vote up
public static void setValueBinding(UIComponent component, String attributeName,
        String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 13
Project: sakai   File: RendererUtil.java   View source code 6 votes vote down vote up
/**
 * Sets component attribute value - if a ValueBinding exists for that
 * attribute, set through the binding; otherwise, set the value directly on
 * the component.
 */
public static void setAttribute(FacesContext context, UIComponent component, String name,
        Object value)
{
    ValueBinding binding = component.getValueBinding(name);
    if (binding != null)
    {
        try
        {
            binding.setValue(context, value);
        } catch (IllegalArgumentException e)
        {
            // try setting the value as a String
            binding.setValue(context, String.valueOf(value));
        }
    } else
    {
        component.getAttributes().put(name, value);
    }
}
 
Example 14
Project: GeoprocessingAppstore   File: UIJscript.java   View source code 6 votes vote down vote up
/**
 * Read value.
 * 
 * @return the string
 */
public String readValue () {
  Object name = this.getAttributes().get(Options.value.name());
  if(name == null) {
    return "";
  }
  if(name instanceof ValueBinding) {
    name = ((ValueBinding) name).getValue(this.getFacesContext());
    if(name == null) {
      return "";
    }
    else return name.toString();
  }
  else if(name instanceof String) {
    return name.toString();
  }
  return "";
}
 
Example 15
Project: community-edition-old   File: UINodeDescendants.java   View source code 6 votes vote down vote up
/**
 * @return the maximum number of child descendants to be displayed, default maximum is 3. 
 */
public int getMaxChildren()
{
   ValueBinding vb = getValueBinding("maxChildren");
   if (vb != null)
   {
      this.maxChildren = (Integer)vb.getValue(getFacesContext());
   }
   
   if (this.maxChildren != null)
   {
      return this.maxChildren.intValue();
   }
   else
   {
      // return default
      return 3;
   }
}
 
Example 16
Project: GeoprocessingAppstore   File: UIPagination.java   View source code 6 votes vote down vote up
private PageCursor getCriteriaPageCursor() {
  PageCursor pageCursor = null;
  try {
    
  Object pageCursorObj = this.getAttributes()
  .get(ComponentMapKeys.criteriaCursor.name());
   pageCursorObj = ((ValueBinding) pageCursorObj)
  .getValue(this.getFacesContext());
   if(pageCursorObj instanceof PageCursor) {

    pageCursor = (PageCursor) pageCursorObj;

   } else {
    throw new ConfigurationException("Search Criteria PageCursor in JSF " +
    		"Paginator should be an"  //$NON-NLS-1$
      + "instance of " + PageCursor.class.getCanonicalName()); //$NON-NLS-1$
   }
  } catch (Throwable t) {
    // for backward compatibility
    return this.getPageCursor();
  }

   return pageCursor;
}
 
Example 17
Project: sakai   File: TocTreeTag.java   View source code 6 votes vote down vote up
/** 
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component)
{
  super.setProperties(component);
  FacesContext context = getFacesContext();
  if (value != null)
  {
    ValueBinding vb = context.getApplication().createValueBinding(value);
    component.setValueBinding("value", vb);
  }
  if (var != null)
  {
    ((UIData) component).setVar(var);
  }

}
 
Example 18
Project: sakai   File: RendererUtil.java   View source code 6 votes vote down vote up
/**
 * Sets component attribute value - if a ValueBinding exists for that
 * attribute, set through the binding; otherwise, set the value directly on
 * the component.
 */
public static void setAttribute(FacesContext context, UIComponent component, String name,
        Object value)
{
    ValueBinding binding = component.getValueBinding(name);
    if (binding != null)
    {
        try
        {
            binding.setValue(context, value);
        } catch (IllegalArgumentException e)
        {
            // try setting the value as a String
            binding.setValue(context, String.valueOf(value));
        }
    } else
    {
        component.getAttributes().put(name, value);
    }
}
 
Example 19
Project: myfaces-trinidad   File: FastRenderer.java   View source code 5 votes vote down vote up
protected Converter getConverterByType(
  FacesContext   context,
  CoreOutputText cot)
{
  ValueBinding binding = cot.getFacesBean().getValueBinding(_valueKey);
  if (binding == null)
    return null;

  Class<?> type = binding.getType(context);
  return ConverterUtils.createConverter(context, type);
}
 
Example 20
Project: myfaces-trinidad   File: MApplication.java   View source code 5 votes vote down vote up
@Override
public ValueBinding createValueBinding(String expression)
{
  if (!expression.startsWith("#{") ||
      !expression.endsWith("}"))
    throw new UnsupportedOperationException("Haven't implemented that much yet!");
  return new MValueBinding(expression);
}
 
Example 21
Project: myfaces-trinidad   File: MApplication.java   View source code 5 votes vote down vote up
public ValueExpression createValueExpression(
   ELContext context, String expression, Class<?> expectedType)
{
  // TODO handle coercion
  ValueBinding vb = MApplication.this.createValueBinding(expression);
  return new ValueBindingValueExpression(vb);
}
 
Example 22
Project: myfaces-trinidad   File: FastRenderer2.java   View source code 5 votes vote down vote up
protected Converter getConverterByType(
  FacesContext context,
  FacesBean    bean)
{
  ValueBinding binding = bean.getValueBinding(_valueKey);
  if (binding == null)
    return null;

  Class<?> type = binding.getType(context);
  return ConverterUtils.createConverter(context, type);
}
 
Example 23
Project: myfaces-trinidad   File: UIXComponentTag.java   View source code 5 votes vote down vote up
protected final ValueBinding createValueBinding(String string)
{
  if (_parentELContext != null)
    string = _parentELContext.transformExpression(string);

  return getFacesContext().getApplication().createValueBinding(string);
}
 
Example 24
Project: myfaces-trinidad   File: SkinAddition.java   View source code 5 votes vote down vote up
/**
 * Constructor takes a styleSheet name and a translationSource ValueBinding.
 * ValueBinding is deprecated, use ValueExpression for setting the translationSource
 * @deprecated Use builder to create a SkinAddition object.
 * @See Builder
 */
@Deprecated
public SkinAddition (
  String       styleSheetName,
  ValueBinding translationSourceValueBinding
  )
{
  _styleSheetName = styleSheetName;
  _resourceBundleName = null;
  _translationSourceVE = null;
  _translationSourceVB = translationSourceValueBinding;
  _skinFeatures = null;
  _skinId = null;
}
 
Example 25
Project: myfaces-trinidad   File: UIXComponentBase.java   View source code 5 votes vote down vote up
@Override
public void setValueBinding(String name, ValueBinding binding)
{
  if (name == null)
    throw new NullPointerException();

  PropertyKey key = getPropertyKey(name);
  getFacesBean().setValueBinding(key, binding);
}
 
Example 26
Project: myfaces-trinidad   File: ValueBindingValueExpression.java   View source code 5 votes vote down vote up
private ValueBindingValueExpression(ValueBinding binding)
{
  if (binding == null)
    throw new NullPointerException();
  
  _binding = binding;
}
 
Example 27
Project: myfaces-trinidad   File: FacesBeanImpl.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final public ValueBinding getValueBinding(PropertyKey key)
{
  ValueExpression ve = getValueExpression(key);

  if (ve == null)
  {
    return null;
  }
  else
  {
    // wrap the ValueExpression if necessary
    return ValueExpressionValueBinding.getValueBinding(ve);
  }
}
 
Example 28
Project: myfaces-trinidad   File: ChangeManager.java   View source code 5 votes vote down vote up
@Override
public DocumentChange convert(ComponentChange compChange)
{
  if (compChange instanceof AttributeComponentChange)
  {
    AttributeComponentChange change = (AttributeComponentChange)compChange;

    Object value = change.getAttributeValue();

    // =-= bts TODO add registration of attribute converters
    String valueString = null;
    if ((value == null) ||
        (value instanceof CharSequence) ||
        (value instanceof Number) ||
        (value instanceof Boolean))
    {
      valueString = (value != null)? value.toString() : null;
    }
    else if (value instanceof ValueExpression)
    {
      valueString = ((ValueExpression)value).getExpressionString();
    }
    else if (value instanceof ValueBinding)
    {
      valueString = ((ValueBinding)value).getExpressionString();
    }
    
    if (valueString != null)
      return new AttributeDocumentChange(change.getAttributeName(),
                                         valueString);
  }

  // no conversion possible
  return null;
}
 
Example 29
Project: myfaces-trinidad   File: RowKeySetAttributeChange.java   View source code 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void changeComponent(UIComponent component)
{
  Map<String, Object> attributeMap = component.getAttributes();

  Object newAttributeValue = getAttributeValue();
  String attrName  = getAttributeName();
  
  if ((newAttributeValue instanceof RowKeySet) || (newAttributeValue == null))
  {
    // Specially handle RowKeySet case by replacing the contents of the RowKeySet in-place
    // rather than replacing the entire object.  This keeps the mutable object instance from
    // changing
    _updateRowKeySetInPlace(component, attrName, (RowKeySet)newAttributeValue);
  }
  else if (newAttributeValue instanceof ValueExpression)
  {
    // if the new attribute value is a ValueExpession, set it and remove the old value
    // so that the ValueExpression takes precedence
    component.setValueExpression(attrName, (ValueExpression)newAttributeValue);
    attributeMap.remove(attrName);
  }
  else if (newAttributeValue instanceof ValueBinding)
  {
    // if the new attribute value is a ValueBinding, set it and remove the old value
    // so that the ValueBinding takes precedence
    component.setValueBinding(attrName, (ValueBinding)newAttributeValue);
    attributeMap.remove(attrName);
  }
  else
  {
    // perform the default behavior
    attributeMap.put(attrName, newAttributeValue);
  }
}
 
Example 30
Project: myfaces-trinidad   File: UIComponentTestCase.java   View source code 5 votes vote down vote up
/**
 * Tests the update-model-values lifecycle phase.
 */
protected void doTestUpdateModelValues(
  UIViewRoot  root,
  UIComponent component)
{

  Mock mockRenderkit = getMockRenderKitWrapper().getMock();

  Mock mockRenderer = mock(Renderer.class);
  Renderer renderer = (Renderer) mockRenderer.proxy();
  mockRenderkit.stubs().method("getRenderer").will(returnValue(renderer));

  Mock mockBinding = mock(ValueBinding.class);
  ValueBinding binding = (ValueBinding) mockBinding.proxy();

  setCurrentContext(facesContext);

  // if the component is an EditableValueHolder, then the value binding
  // must be updated with the new value before this phase completes.
  if (component instanceof EditableValueHolder)
  {
    EditableValueHolder editable = (EditableValueHolder)component;
    component.setValueBinding("value", binding);
    editable.setValue("newValue");
    mockBinding.expects(atLeastOnce()).method("setValue").with(eq(facesContext), eq("newValue"));

    assertEquals(true, editable.isLocalValueSet());
  }

  doTestUpdateModelValues(facesContext, root, component);

  setCurrentContext(null);

  mockRenderer.verify();
  mockBinding.verify();
}
 
Example 31
Project: parabuild-ci   File: JsfCreator.java   View source code 5 votes vote down vote up
public Object getInstance() throws InstantiationException
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null)
    {
        log.error("Object " + getManagedBeanName() + " cannot be created since the faces context is null");
        return null;
    }

    Application application = facesContext.getApplication();
    Object resolvedObject = null;

    if (isVBExpression(getManagedBeanName()))
    {
        ValueBinding vb = application.createValueBinding(getManagedBeanName());
        if (vb != null)
        {
            resolvedObject = vb.getValue(facesContext);
        }
    }
    else
    {
        VariableResolver resolver = application.getVariableResolver();
        resolvedObject = resolver.resolveVariable(facesContext, getManagedBeanName());
    }

    return resolvedObject;
}
 
Example 32
Project: dwr   File: JsfCreator.java   View source code 5 votes vote down vote up
@Override
public Object getInstance() throws InstantiationException
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null)
    {
        log.error("Object " + getManagedBeanName() + " cannot be created since the faces context is null");
        return null;
    }

    Application application = facesContext.getApplication();
    Object resolvedObject = null;

    if (isVBExpression(getManagedBeanName()))
    {
        ValueBinding vb = application.createValueBinding(getManagedBeanName());
        if (vb != null)
        {
            resolvedObject = vb.getValue(facesContext);
        }
    }
    else
    {
        VariableResolver resolver = application.getVariableResolver();
        resolvedObject = resolver.resolveVariable(facesContext, getManagedBeanName());
    }

    return resolvedObject;
}
 
Example 33
Project: sakai   File: TagUtil.java   View source code 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
  String attributeName,
  String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 34
Project: sakai   File: ContextSensitiveTreeTag.java   View source code 5 votes vote down vote up
/** 
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component)
{
  super.setProperties(component);
  FacesContext context = getFacesContext();
  if (value != null)
  {
    ValueBinding vb = context.getApplication().createValueBinding(value);
    component.setValueBinding("value", vb);
  }
  if (var != null)
  {
    ((UIData) component).setVar(var);
  }

  if (getHelpDocId() != null)
  {
    if (isValueReference(getHelpDocId()))
    {
      component.setValueBinding("helpDocId", getFacesContext()
          .getApplication().createValueBinding(getHelpDocId()));
    }
    else
    {
      component.getAttributes().put("helpDocId", getHelpDocId());
    }
  }
}
 
Example 35
Project: sakai   File: GradebookItemTableRenderer.java   View source code 5 votes vote down vote up
private int getNumDataItemsForToggle(FacesContext context, UIComponent component) {
	int numDataItems = 0;
	ValueBinding gbItemsBinding = component.getValueBinding("value");
	List gbItemList = (List)gbItemsBinding.getValue(context);
	if (gbItemList != null && !gbItemList.isEmpty()) {
		numDataItems = gbItemList.size();
	}
	return numDataItems;
}
 
Example 36
Project: sakai   File: IteratorComponent.java   View source code 5 votes vote down vote up
protected Object getFieldOrBinding(Object field, String bindingName) {
	Object retVal = null;
	if (field != null) {
		retVal = field;
	} else {
		ValueBinding binding = getValueBinding(bindingName);
		if (binding != null) {
			retVal = binding.getValue(getFacesContext());
		}
	}
	return retVal;
}
 
Example 37
Project: sakai   File: FlowStateTag.java   View source code 5 votes vote down vote up
protected void setProperties(UIComponent component) {
	if (log.isDebugEnabled()) log.debug("setProperties " + bean);
	super.setProperties(component);

	FacesContext context = getFacesContext();

	if (bean != null) {
		if (UIComponentTag.isValueReference(bean)) {
			ValueBinding vb = context.getApplication().createValueBinding(bean);
			component.setValueBinding("bean", vb);
		} else {
			log.error("Invalid expression " + bean);
		}
	}
}
 
Example 38
Project: sakai   File: TagUtil.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 39
Project: sakai   File: RendererUtil.java   View source code 5 votes vote down vote up
/**
 * Return the attribute value - handles getting the value from a
 * ValueBinding if necessary. This is necessary because of a difference in
 * the Sun JSF RI versus the MyFaces RI. The Sun RI
 * component.getAttributes().get(attrName) will automatically return value
 * bindings, whereas the MyFaces implmentation requires getting values from
 * ValueBinding seperately.
 */
public static Object getAttribute(FacesContext context, UIComponent component, String name)
{
    // first check the attributes
    Object ret = component.getAttributes().get(name);
    if (ret != null)
        return ret;

    // next check the value bindings
    ValueBinding vb = component.getValueBinding(name);
    if (vb != null)
        ret = vb.getValue(context);

    return ret;
}
 
Example 40
Project: sakai   File: FlowState.java   View source code 5 votes vote down vote up
public PhaseAware getBean() {
	PhaseAware bean = null;
	ValueBinding vb = getValueBinding("bean");
	if (vb != null) {
		bean = (PhaseAware) vb.getValue(getFacesContext());
	}
	if (log.isDebugEnabled()) log.debug("getBean " + bean);
	return bean;
}