In the example you'll note that the tree graph is stored in the session once it 
is created. Are you
doing the same after loading the nodes from the db or are you always reloading 
from the db each request?

Click is a stateless framework, it doesn't store the tree model between 
requests.

regards

Bob

On 2011/03/24 12:18 PM, Reinhard Hnat wrote:
> I have compared the resulting HTML-Pages with the example you sent and cannot 
> see a difference. What
> i have done is to imitate the example given on the Javadoc for Checkboxtree. 
> Only the Information
> for the nodes comes from a database. I give you a code snippet maybe you can 
> see what's wrong:
> 
>     public void CreateSubTree(TreeNode parentnode,Integer level) {
>         String parent="";
>         TreeNode node=null;
>         try {
>             parent=rs.getString(level);
>         } catch (SQLException e) {
>             e.printStackTrace();
>         }
>         node=new TreeNode(parent,nodeNumber.toString());
>         parentnode.add(node);
>         nodeNumber++;
>         try {
>             if  ((!rs.getMetaData().getColumnName(level+1).equals("kanalid") 
> && !rs.isAfterLast())) {
>                 for (;parent.equals(rs.getString(level)) && !rs.isLast();)  {
>                     CreateSubTree(node,level+1);
>                     rs.next();
>                     }
>                 }
>         } catch (SQLException e) {
>             e.printStackTrace();
>         }
>     }
>        
> 
>     public Select() throws SQLException{
>         CheckboxTree tree;
>        
>         db=new Database();
>         conn=db.getConnection();
>         tree=new CheckboxTree("tree");
>         addControl(tree);
> 
>        
>         stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
>                 ResultSet.CONCUR_READ_ONLY);
>         rs=stmt.executeQuery("select owner,stationsname,kanalname,kanalid 
> from stationen left join
> kanaele using(stationid) " +
>                 "order by owner,stationsname,kanalname");
>         rs.first();
>         rs.next();
>         TreeNode root = new TreeNode("rootnode","0");
> 
>         nodeNumber=1;
>         CreateSubTree(root,1);
>         tree.setRootNode(root);
>         tree.setRootNodeDisplayed(true);
>            rs.getMetaData().getColumnName(j);
>      
>         tree.expandAll();
>        
>         addModel("tree",tree);
>         stmt.close();
>         }
> 
> <html>
>   <head>
>     <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8">
>     <title>Select</title>
>   $imports
>   </head>
>   <body>
>   $tree
>   $jsElements
>   </body>
> </html>
> 
> Regards Reinhard
> 
> Am 2011-03-24 10:22, schrieb Bob Schellink:
>> Hi Reinhard,
>>
>> Here is an example of the checbox tree[1] which works properly. Also look at 
>> the source code of
>> that example and compare against your own code.
>>
>> regards
>>
>> Bob
>>
>> [1]: http://click.avoka.com/click-examples/tree/checkbox-tree-page.htm
>>
>> On 2011/03/24 11:16 AM, Reinhard Hnat wrote:
>>>
>>> Hi There!
>>>
>>> I am using the CheckboxTree component. But it has a strange behaviour. When 
>>> i create the tree everything is fine and all Nodes are displayed. 
>>> Collapsing a node is also no problem. But when i try to reexpand the node 
>>> (by clicking at the "+" sign) it does not work, When i click at the "-" 
>>> sign of the next node in the same hierarchy the node which was collapsed 
>>> before gets expanded. 
>>>
>>> Does anyone know this problem and what to do?
>>>
>>> Thanks in advance
>>> Reinhard
>>

Reply via email to