Java Code Examples for javax.faces.el.ValueBinding#setValue()

The following examples show how to use javax.faces.el.ValueBinding#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 2
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 3
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 4
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 5
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 6
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 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 7
Source File: FlowStateComponent.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void restoreState(FacesContext context, Object state) {
	if (log.isDebugEnabled()) log.debug("restoreState " + state);
	Object values[] = (Object[])state;
	super.restoreState(context, values[0]);
	PhaseAware bean = (PhaseAware)values[1];
	ValueBinding vb = getValueBinding("bean");
	if (vb != null) {
		vb.setValue(context, bean);
	}
}
 
Example 8
Source File: FlowState.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void restoreState(FacesContext context, Object state) {
	if (log.isDebugEnabled()) log.debug("restoreState " + state);
	Object values[] = (Object[])state;
	super.restoreState(context, values[0]);
	PhaseAware bean = (PhaseAware)values[1];
	ValueBinding vb = getValueBinding("bean");
	if (vb != null) {
		vb.setValue(context, bean);
	}
}
 
Example 9
Source File: ExtLibUtil.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static void assignBindingProperty(FacesContext context, String bindingExpr, UIComponent component) {
    ValueBinding binding = ((ApplicationEx)context.getApplication()).createValueBinding(bindingExpr);
    if( binding.isReadOnly(context) ){
        return;
    }
    if( binding instanceof ComponentBindingObject ){
        ((ComponentBindingObject)binding).setComponent(component);
    }
    binding.setValue(context, component);
    component.setValueBinding("binding", binding); //$NON-NLS-1$
}
 
Example 10
Source File: FlowStateComponent.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void restoreState(FacesContext context, Object state) {
	if (log.isDebugEnabled()) log.debug("restoreState " + state);
	Object values[] = (Object[])state;
	super.restoreState(context, values[0]);
	PhaseAware bean = (PhaseAware)values[1];
	ValueBinding vb = getValueBinding("bean");
	if (vb != null) {
		vb.setValue(context, bean);
	}
}
 
Example 11
Source File: FlowState.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void restoreState(FacesContext context, Object state) {
	if (log.isDebugEnabled()) log.debug("restoreState " + state);
	Object values[] = (Object[])state;
	super.restoreState(context, values[0]);
	PhaseAware bean = (PhaseAware)values[1];
	ValueBinding vb = getValueBinding("bean");
	if (vb != null) {
		vb.setValue(context, bean);
	}
}