⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treemodeladapter.java

📁 adf-faces 甲骨文的jsf组件,功能很强.开源免费.
💻 JAVA
字号:
package oracle.adfdemo.view.faces;
import java.beans.IntrospectionException;
import java.util.List;
import oracle.adf.view.faces.model.ChildPropertyTreeModel;
import oracle.adf.view.faces.model.TreeModel;

/**
 * This class facilitates the construction of a ChildPropertyTreeModel instance
 * via managed-beans. ChildPropertyTreeModel does not have a no-arg constructor.
 * This class does, and so can be instantiated as a managed-bean.
 * Two properties need to be set: "childProperty" and "instance"
 */
public class TreeModelAdapter implements java.io.Serializable
{
  public TreeModelAdapter()
  {
  }

  private String _propertyName = null;
  private Object _instance = null;
  private transient TreeModel _model = null;

  public TreeModel getModel() throws IntrospectionException
  {
    if (_model == null)
    {
      _model = new ChildPropertyTreeModel(getInstance(), getChildProperty());
    }
    return _model;
  }

  public String getChildProperty()
  {
    return _propertyName;
  }

  /**
   * Sets the property to use to get at child lists
   * @param propertyName
   */
  public void setChildProperty(String propertyName)
  {
    _propertyName = propertyName;
    _model = null;
  }

  public Object getInstance()
  {
    return _instance;
  }

  /**
   * Sets the root list for this tree.
   * @param instance must be something that can be converted into a List
   */
  public void setInstance(Object instance)
  {
    _instance = instance;
    _model = null;
  }
  
  /**
   * Sets the root list for this tree.
   * This is needed for passing a List when using the managed bean list  
   * creation facility, which requires the parameter type is List.
   * @param instance the list of root nodes
   */
  public void setListInstance(List instance)
  {
    setInstance(instance);
  }  
  
  /**
   * This should only be called if setListInstance was called.
   * 
   * This method shouldn't be needed according to 
   * faces spec 1.1 rev 1, see 5.3.1.3
   * However without this we get the following error in websphere:
   *                java.beans.IntrospectionException: No method 
   *                            "getListInstance" with 0 arg(s) of 
   *                            matching types in websphere
   */
  public List getListInstance()
  {
    return (List)getInstance();
  }
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -