【问题标题】:Disclosing node in ADF Tree在 ADF 树中显示节点
【发布时间】:2013-11-04 17:43:05
【问题描述】:

我在 jsff 页面中使用 af:tree ADF 组件。 af:tree 中使用的模型是这样的一个类(这个类不是基于 ViewObject):

public class TreeItem {
  String description;
  List<TreeItem> children;
}

如何披露仅匹配某些描述的节点?在网上,我只找到了基于 ViewObject 的 af:tree 模型的示例。

【问题讨论】:

    标签: jsf tree oracle-adf


    【解决方案1】:

    您似乎没有使用 ADF BC。您将必须管理 TreeTable 的公开RowKeys,然后在 rowDisclosureListener 的处理程序中,您可以根据描述是否符合要求来更新公开的RowKeys。公开的RowKeys的内容就是RowKeySet的实例。

    <af:treeTable disclosedRowKeys="#{myBean.disclosedRowKeys}" 
                  rowDisclosureListener="#{myViewBean.handleRowDisclosure}">
    </af:treeTable>
    

    在 bean 中:

    class MyPageBean{
      RowKeySet disclosedRowKeys;
      //getters and setters.
    }
    

    在视图 bean 中:

    class MyViewBean{
      public void handleRowDisclosure(RowDisclosureEvent event)
      {
        //get the addedSet OR removedSet - because the event can be expanding or collapsing row.
        //obtain the collection model from the tree table.
        //use the above collection model and the addedSet OR removedSet to get the exact instance of TreeItem.
        if TreeItem.description is satisfied then
          getDisclosedRowKeys from the page model and then add/remove the keys obtained in the addedSet OR removedSet.
    
        partially refresh the treeTable.
      }
    }
    

    我目前无法尝试这种逻辑。不过等我回去工作后会试一试的。

    【讨论】:

    • 当节点是TreeItem类的实例时,如何设置“#{myBean.disclosedRowKeys}”的内容?谢谢
    • RowKey 的内容是索引,即数据在树表中的索引。您可以在我的一篇博客文章中了解更多信息:blog.sanaulla.info/2013/05/13/… 因此,您的节点是 TreeItem 类的实例还是其他类的实例都没有关系。在任何情况下,您都将使用 ChildPropertyTreeModel 实例包装您的 TreeItem 列表。
    【解决方案2】:

    披露一个树节点取决于树组件本身而不是它的模型,如果您想以编程方式披露它,请参阅this article,其中解释了这一点

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多