incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sonja Löhr <sonjalo...@arcor.de>
Subject <tr:tree> no Children inited
Date Fri, 03 Nov 2006 10:23:26 GMT
Hi!
Could someone tell me where I am wrong that my <tr:tree> always displays
just the root elements?
As the tree inited from the persistence layer (using Seam and EJB3) did not
work, I stepped back and setup the following simple test, but still I do not
see any "open" handles, nor is the "getChildren" getter on my TestBean ever
called, therefore  the log message in getModel() also states a tree depth of
zero. On the adapter I removed some "model = null" instructions during
debugging.

Here is the <tr:tree>, the classes used and the faces-config.xml part.

Any help would be great!
Thanks in advance!




   <tr:tree id="grouptree" var="cat" value="#{groupsAdapter.model}">
           <f:facet name="nodeStamp">
              <tr:commandLink text="#{cat.name}" styleClass="nodeText">
                 <!--  outcommented actionListener  -->
                 </tr:commandLink>

           </f:facet>
   </tr:tree>


============================================================================
=========
	
 <managed-bean>
       <managed-bean-name>treeTest</managed-bean-name>
       <managed-bean-class>japp.jsf.TreeTest</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>     
  </managed-bean>

 <managed-bean>
       <managed-bean-name>groupsAdapter</managed-bean-name>
       <managed-bean-class>japp.jsf.TreeModelAdapter</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
            <property-name>instance</property-name>
            <value>#{treeTest.roots}</value>
        </managed-property>
        <managed-property>
            <property-name>childPropertyName</property-name>
            <value>children</value>
        </managed-property>
 </managed-bean>


============================================================================
===0


public class TreeModelAdapter {

	private String childPropertyName;
	private Object _instance = null;
	private transient TreeModel _model = null;
	    
	Log logger = LogFactory.getLog(TreeModelAdapter.class);
	    
	public TreeModelAdapter() {}
	        

	public TreeModel getModel() throws IntrospectionException    {
	      if (_model == null)  {
	        _model = new ChildPropertyTreeModel(getInstance(),
getChildPropertyName());
	      }
	      logger.info("Tree depth: "+_model.getDepth());
	      return _model;
	}

	public String getChildPropertyName()   {
	     return childPropertyName;
	}

	public void setChildPropertyName(String propertyName)   {
	  	childPropertyName = propertyName;	     
	}

	 public Object getInstance() {
	     return _instance;
	 }


    public void setInstance(Object instance)   {
      _instance = instance;
    }
    
	    
	public void setListInstance(List<Object> instance) {
	     setInstance(instance);
	}  
	    
	    
	@SuppressWarnings("unchecked")
	public List<Object> getListInstance()   {
	     return (List<Object>)getInstance();
	}
	    
	    
}



============================================================================
==

public class TreeTest {
	
	public TreeTest() {
		
	}
	
	private List<TestBean> roots;
	  
    public List<TestBean> getRoots() {
    	if(roots != null) return roots;
    	roots = new ArrayList<TestBean>();
    	TestBean r1 = new TestBean("root1");
    	TestBean ch1 = new TestBean("ch1");
    	TestBean enk11 = new TestBean("enk1");
    	ch1.addChild(enk11);
    	r1.addChild(ch1);
    	
    	TestBean r2 = new TestBean("root2");
    	TestBean ch2 = new TestBean("ch2");
    	TestBean enk21 = new TestBean("enk21");
    	TestBean enk22 = new TestBean("enk22");
    	ch2.addChild(enk21);
    	ch2.addChild(enk22);
    	r2.addChild(ch2);
    	TestBean ch3 = new TestBean("ch3");
    	TestBean enk23 = new TestBean("enk23");
    	ch3.addChild(enk23);
    	r2.addChild(ch3);
    	roots.add(r1);
    	roots.add(r2);
    	return roots;
    }
}


============================================================================
====

public class TestBean {
	private List<TestBean> children;
	private String name;
	
	public TestBean() {
		children = new ArrayList<TestBean>();
	}
	public TestBean(String name) {
		this.name = name;
		children = new ArrayList<TestBean>();
	}
	public void addChild(TestBean ch) {
		children.add(ch);
	}
	//never called !!
	public List<TestBean> getChildren() {
		System.out.println("getChildren called on "+name);
		System.out.print("getChildren returns: ");
		for(TestBean ch : children) {
			System.out.print(ch.toString());
		}
		System.out.println();
		return children;
	}
	
	public void setChildren(List<TestBean> children) {
		this.children = children;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String toString() {
		return name+" kids: "+children.size();
	}	
}

    
    



Mime
View raw message