當前位置: 首頁>>代碼示例>>Java>>正文


Java UIComponent.setValueBinding方法代碼示例

本文整理匯總了Java中javax.faces.component.UIComponent.setValueBinding方法的典型用法代碼示例。如果您正苦於以下問題:Java UIComponent.setValueBinding方法的具體用法?Java UIComponent.setValueBinding怎麽用?Java UIComponent.setValueBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.component.UIComponent的用法示例。


在下文中一共展示了UIComponent.setValueBinding方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: changeComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * {@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);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:29,代碼來源:AttributeComponentChange.java

示例2: changeComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@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);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:37,代碼來源:RowKeySetAttributeChange.java

示例3: doTestUpdateModelValues

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:39,代碼來源:UIComponentTestCase.java

示例4: apply

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void apply(FacesContext context, UIComponent component)
{
  Iterator<Test> tests = _delegateTests.iterator();
  
  if (_testComponentId != null)
    component = component.findComponent(_testComponentId); 
  
  while (tests.hasNext())
  {
    Test test = tests.next();
    test.apply(context, component);
  }
  
  Object value = _value;
  
     
  // Hack to test table sort. This is a custom attribute not renderer or component attribute
  if ("tableSortCriteria".equals(_name))
  {
    UIXCollection tableModel = (UIXCollection)  component;
    List<SortCriterion> sortCriteriaList = new ArrayList<SortCriterion>();
    String sortCriterion = (String) _value;
    Boolean isAscending  = 
       new Boolean(sortCriterion.substring(sortCriterion.indexOf(" ")).trim());
    sortCriteriaList.add(new SortCriterion(
          sortCriterion.substring(0,sortCriterion.indexOf(" ")), 
          isAscending.booleanValue()));
    tableModel.setSortCriteria(sortCriteriaList);
  }
  else
  {      
    if ((value instanceof String) &&
        ComponentDefinition.isValueExpression(value.toString()))
    {
      ValueBinding binding = context.getApplication().
        createValueBinding(value.toString());
      component.setValueBinding(_name, binding);
    }
    else
    {
      if (value == null)
        value = "test-" + _name;
  
      component.getAttributes().put(_name, value);
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:50,代碼來源:TestScript.java


注:本文中的javax.faces.component.UIComponent.setValueBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。