Java Code Examples for javax.faces.component.UIComponent.setValueExpression()

The following are Jave code examples for showing how to use setValueExpression() of the javax.faces.component.UIComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: myfaces-trinidad   File: AttributeComponentChange.java   Source Code and License Vote up 6 votes
/**
 * {@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 2
Project: javaee8-applications   File: ColumnModelController.java   Source Code and License Vote up 5 votes
/**
 * Called as preprocessor to export (after clicking Excel icon) to capture
 * the table component and call upon createDynamicColumns()
 *
 * @since 2.7.5
 */
public void updateColumns() {
    //reset table state
    UIComponent table = FacesContext.getCurrentInstance().getViewRoot().findComponent(":customerExportForm:customerTable");
    table.setValueExpression("sortBy", null);

    //update columns
    createDynamicColumns();
}
 
Example 3
Project: myfaces-trinidad   File: RowKeySetAttributeChange.java   Source Code and License Vote up 5 votes
@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);
  }
}