Why does this example interface tree not work?

Hi I wrote a simple example for a richfaces tree tag, but it only extends the root nodes (but does not collapse them back) xhtml code:

   <rich:panel id="unitTest" width="240" height="400">
      <h:form>
      <rich:tree>
         <rich:recursiveTreeNodesAdaptor roots="#{tree.nodes}" var="item" nodes="#{item.nodes}" >
            <rich:treeNode>
               <h:outputText value="#{item}"/>
            </rich:treeNode> 
         </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      </h:form>
   </rich:panel>

java bean code:

import java.util.*;

public class UnitTreeNode
{
   String name;
   List<UnitTreeNode> children;

   public UnitTreeNode()
   {
      this.name="";
   }
   public UnitTreeNode(String name)
   {
      this.name=name;
   }
   public List<UnitTreeNode> getNodes() 
   {
      if(children==null)
      {
         children=new ArrayList<UnitTreeNode>();
         for(int i=0;i<3;i++)
           children.add(new UnitTreeNode(name+i));
      }
      return children;
   }
   public String toString()
   {
      return name;
   }
}

configurations:

   <managed-bean>
      <managed-bean-name>tree</managed-bean-name>
      <managed-bean-class>UnitTreeNode</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
   </managed-bean>

I use myfaces 1.2.8 and richfaces 3.3.2.SR1, and I do not understand why it does not work.

+3
source share
2 answers

The default problem: treeTypeType is ajax, and your ajax requests are not getting properly sent to the server due to the surrounding tag. (It seems that this is a mistake with the support of wealthy individuals, and it can be solved with the help of subsequent releases).

So here is the solution

  • use <rich:tree switchType="server">
  • or just remove the tag <h:form>

Hope this helps

0
source

3.3.3, facelets.BUILD_BEFORE_RESTORE false web.xml.

<context-param>
  <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
  <param-value>false</param-value>
</context-param>
0

Source: https://habr.com/ru/post/1784398/


All Articles