• JSF Tree学习...


    RAD7.0开发Faces Portlet.使用到Tree组件.
    =====================================

    使用JSF中的<ig:Sidebar></ig:Sidebar>实现动态加载菜单,其中bar.getChildren().add(aSidebarGroup);是实现动态加载首节点,HtmlSidebarGroup aSidebarGroup = (HtmlSidebarGroup) application.createComponent(HtmlSidebarGroup.COMPONENT_TYPE);
        aSidebarGroup.setText(boardName);
        aSidebarGroup.setExpanded(true);
        aSidebarGroup.setId(viewRoot.createUniqueId());实现加载该节点下的子节点,非常方便。

    private Sidebar buildSideBar(Sidebar bar)
     {
      boolean isInitialised = bar.getAttributes().get("IS_INITIALISED")!=null;
      
      if (!isInitialised) {
       // Get a reference to the JSF Application,
       // we need it to create value bindings later-on
       Application application = FacesContext.getCurrentInstance().getApplication();
       UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
       
       /* Create Infragistics SidebarGroup */
       // Set the Sidebar's width and height
       bar.getAttributes().put("style"," 155px; height: 590px;");
       // Create SidebarGroup
       List list = this.getBoardNameForMenu();
       for(int i = 0 ;i<list.size();i++)
       {
        Object[] row = (Object[])list.get(i);
       //Object[] row = (Object[])list.listIterator().next();
        String boardId = String.valueOf(row[0]);
        String boardName = String.valueOf(row[1]);
        String parentId = String.valueOf(row[2]);
        HtmlSidebarGroup aSidebarGroup = (HtmlSidebarGroup) application.createComponent(HtmlSidebarGroup.COMPONENT_TYPE);
        aSidebarGroup.setText(boardName);
        aSidebarGroup.setExpanded(true);
        aSidebarGroup.setId(viewRoot.createUniqueId());
       
        // Add the newly created SidebarGroup to the Sidebar's children list
        bar.getChildren().add(aSidebarGroup);
        
        List ls = this.getBoardNameForMenuBar(Integer.parseInt(boardId));
        if(ls.size() != 0)
        {
         for(int j=0;j<ls.size();j++)
         {
          Object[] row1 = (Object[])ls.get(j);
          String boardid = String.valueOf(row1[0]);
          String boardname = String.valueOf(row1[1]);
          //HtmlSidebarGroup aSidebarGroup = (HtmlSidebarGroup) application.createComponent(HtmlSidebarGroup.COMPONENT_TYPE);
          HtmlLink aLink1 = (HtmlLink)application.createComponent(HtmlLink.COMPONENT_TYPE);
          aLink1.setId(viewRoot.createUniqueId());
          //aSidebarGroup.setText(sidebarGroupNameStr);
          //aSidebarGroup.setExpanded(true);
          //aSidebarGroup.setId(viewRoot.createUniqueId());
          //aLink1.setId(parentId);
          aLink1.setUrl("/pages/bbs/visitor/topic/topicforboard.jsf?boardid="+boardid+"");
          aLink1.setValue(boardname);
          aSidebarGroup.getChildren().add(aLink1);
         }
        }
        
       }

  • 相关阅读:
    hdu 4403 枚举
    hdu 4405概率dp
    lightoj 1036 dp
    lightoj 1033 区间dp
    lightoj 1032 二进制的dp
    hdu 4293 dp求最大权值不重合区间
    poj 2449 第k短路
    hdu 4284 状态压缩
    hdu4281 区间dp
    poj 2288 tsp经典问题
  • 原文地址:https://www.cnblogs.com/kentyshang/p/1213825.html
Copyright © 2020-2023  润新知