0 Replies Latest reply on Apr 18, 2011 4:03 AM by jaipalreddy duvvuru

    Style classes not effecting in dynamic generation of rich faces tree component

    jaipalreddy duvvuru Newbie

      Here is the code:

       

      UI Page:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <f:view xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
      <html>
      <head>

       

      </head>
      <body>

       

      <style>

       

      .rich-pmenu{
        background: none;
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-disabled-element{
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-group{
        color:red;
        border:5px solid green;
        background: none;
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-group-self-label{
      width: 30px;
        height: 30px;
      }
      .rich-pmenu-item{
        background: none;
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-nowrap{
      width: 30px;
        height: 30px;
      }
      .rich-pmenu-selected-element{
        background: none;
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-top-group{
        background: none;
        width: 30px;
        height: 30px;
      }
      .rich-pmenu-top-group-div{
        background: none;
        width: 30px;
        height: 30px;
      }

        </style> 
         <h:form>  
             <h:panelGrid binding="#{dynamicManagedBean.dynaMenu}" dir="#{msg.component_dir}" width="50%">
             </h:panelGrid>
         </h:form>  
      </body>
      </html>
      </f:view>

       

       

       

      Backing Bean:

       

       

      public HtmlPanelGrid buildDynamicMenu(String xmlFileName) throws ComponentException {
        HtmlPanelGrid grid = new HtmlPanelGrid();
        try {
         if (xmlFileName == null || EMPTY_STRING.equalsIgnoreCase(xmlFileName)) {
          throw new ComponentException(JsfRichComponentUtil.getResourceValue(XML_FILE_NAME_IS_NULL));
         }

         uiXmlVo = ComponentUtil.getUiXmlVo(xmlFileName);

         if (uiXmlVo == null) {
          throw new ComponentException(XML_FILE_IS_NULL);
         }
       
        HtmlPanelMenu mainMenu = new HtmlPanelMenu();
        MethodBinding mbButton = JsfRichComponentUtil.getApplication().createMethodBinding("#{dynamicManagedBean.loadMenuContent}", null);
        System.out.println(uiXmlVo.getMenu().toString());
        for (Menu menu : uiXmlVo.getMenu()) {
        
         if(menu.getTreeNode()!=null){
          HtmlPanelMenuGroup group = new HtmlPanelMenuGroup();
          group.setLabel(menu.getLabel());
          group.setIconCollapsed("/images/help.jpg.bmp");
          group.setIconExpanded("/images/help.jpg.bmp");
          group.setStyleClass("rich-pmenu");
          //group.setStyle("background-image:url(/images/side_menu_bg_inactive.jpg);background-repeat:repeat-x;");
          if(!menu.getTreeNode().isEmpty()){
           HtmlPanelMenuItem item = new HtmlPanelMenuItem();
           HtmlTree tree = createTreeMenu(menu.getTreeNode());
           item.getChildren().add(tree);
           item.setIcon("/images/whitespace.jpg");
           item.setStyle("background:none;");
           group.getChildren().add(item);
          }else{
           group.setOnclick("document.getElementById('commonForm2:sss').click()");
          }
          mainMenu.getChildren().add(group);
         }
        }
        grid.getChildren().add(mainMenu);
        grid.setStyle("width:250px");
        } catch (Exception e) {
         throw new ComponentException(e.getMessage(), e);
        }
        return grid;
      }

       

        private  HtmlTree createTreeMenu(List<TreeNode> list)
          {
             HtmlTree hTree = new HtmlTree();
             UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
             hTree.setId("TreeMenu"+viewRoot.createUniqueId());
             MethodBinding mbButton =app.createMethodBinding("#{dynamicManagedBean.processSelection}", new Class[]{NodeSelectedEvent.class });
             root = new TreeNodeImpl<String>();
             root.setData("Root");
             int i = 0;
             for (TreeNode treeNode : list) {
              TreeNodeImpl<String> child = new TreeNodeImpl<String>();
                 root.addChild(i++, child);
                 child.setData(treeNode.getLabel());
               
                for (Leaf leaf : treeNode.getLeaf()) {
                 TreeNodeImpl<String> child1 = new TreeNodeImpl<String>();
                 child1.setData(leaf.getLabel());
                 child.addChild(i++, child1);
         }       
                
        }
             hTree.setSelectedClass("travel0-tree-node-selected");
             hTree.setStyleClass("travel0-tree-node-selected");
             hTree.setIcon("");
             hTree.setIconLeaf("");
             hTree.setIconCollapsed("/images/tree_plus.jpg");
             hTree.setIconExpanded("/images/minus.jpg");
             hTree.setValue(root);
             hTree.setNodeSelectListener(mbButton);
             hTree.setBypassUpdates(true);
             hTree.setSwitchType("client");
             hTree.setAjaxSubmitSelection(true);
             hTree.setReRender("dynamicDataTable");
             return hTree;
          }

       

       

       

      Appreciating the quicker response. Please Let me know the solution ASAP.