1 Reply Latest reply on Mar 17, 2011 5:07 AM by Ilya Shaikovsky

    rich:tree  java.lang.NullPointerException

    Maxim Kuzmik Newbie

      Hello, here is my code:

       

       

      <ui:define name="leftZone">
        <h:form>
         <rich:panel header="Навигация">
          <rich:tree id="navigationTree" var="node"
           value="#{treeManager.rootNodes}" toggleType="ajax"
           selectionType="ajax"
           selectionChangeListener="#{treeManager.selectionChanged}"
           nodeType="#{node.type}" reRender="mainPanel" render="mainPanel">
           <rich:treeNode type="folder">
            #{node.name}
           </rich:treeNode>
          </rich:tree>
         </rich:panel>
        </h:form>
       </ui:define>
      

       

      public void initTree() throws AsgeMetaException, AsgeEssenceOperationException {
          if (rootFolderId != null) {
            currentSelection = null;
            rootNodes.clear();
            // Получаем саму папку.
            AsgeEssenceId folderId = new AsgeEssenceId(rootFolderId);
            AsgeEssenceOperationManager eom = new AsgeEssenceOperationManager(folderId);
            eom.setGetLinkedObjects(false);
            AsgeFolder folder = (AsgeFolder) eom.getOne();
            // Добавляем саму папку в дерево (TODO: временно на стадии отладки)
            AsgeTreeNode node = new AsgeTreeNode(folder, null);
            node.setName(folder.getTitle());
            rootNodes.add(node);
          } else {
            rootNodes.clear();
          }
          if (tree != null) {
            tree.clearInitialState();
            tree.setRowKey(null);
            tree.setSelection(null);
            tree.setIterationState(null);
            tree.setRowKey(FacesContext.getCurrentInstance(), null);
            tree.setData(null);
          }
        }
      
      /**
         * Выбор элемента дерева.
         * 
         * @param selectionChangeEvent
         *          selectionChangeEvent
         */
        public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent) {
          Collection<Object> selectionColl = selectionChangeEvent.getNewSelection();
          if (selectionColl != null) {
            List<Object> selection = new ArrayList<Object>(selectionColl);
            Object currentSelectionKey = selection.get(0);
            tree = (UITree) selectionChangeEvent.getSource();
            Object storedKey = tree.getRowKey();
            tree.setRowKey(currentSelectionKey);
            currentSelection = (TreeNode) tree.getRowData();
            tree.setRowKey(storedKey);
            isSelectionChanged = true;
            @SuppressWarnings("unchecked")
            AsgeExtendedDataTableModel<? extends AsgeEssence> dataModel = (AsgeExtendedDataTableModel<? extends AsgeEssence>) javax.faces.context.FacesContext
                .getCurrentInstance().getExternalContext().getSessionMap().get("extDataModel");
            dataModel.setSelectedNode(currentSelection);
          }
        }
      
      

       

      All is fine until i try to refreshpage - F5 i get the error

       

      15.03.2011 15:10:52 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
      SEVERE: Error Rendering View[/WEB-INF/flows/controlpanel/main.xhtml]
      java.lang.NullPointerException
              at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:60)
              at org.richfaces.component.AbstractTogglePanel.encodeBegin(AbstractTogglePanel.java:168)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1641)
              at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:278)
              at org.richfaces.renderkit.html.PopupPanelRenderer.encodeEnd(PopupPanelRenderer.java:534)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)