Hi,

 

 

I needed a tree component that uses lazy load + ajax.

 

Each node expand should go to the server using ajax and ask (hibernate) for extra nodes.

 

I came up with the following solution but I'm not sure about it.

 

I subclassed tree2 so it would render tree content in _javascript_.

 

I changed method EncodeChildren that instead of writing the response it generates _javascript_

 

So it goes:

 

out.write("var treeContent ='"); (line I added)

 

EncodeTree....

 

out.write("getFrame().document.all['" + selectedNodeId + "'].innerHTML = treeContent;"); (line I added)

 

I also added to function encodeCurrentNode a div inside which the content goes.

 

out.startElement(HTML.DIV_ELEM, tree);

String divId = "open_" + createSpanId(tree.getId(),tree.getNodeId());

out.writeAttribute(HTML.ID_ATTR,divId,"");

out.endElement(HTML.DIV_ELEM);

 

An Ajax phaselistener gets the request and calls the component to render itself.

 

Is it a right approach - I have a feeling that its not and would appreciate your feedback

 

Thanks , Tali


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

Reply via email to