You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Tali Garsiel <tg...@mercury.com> on 2005/10/11 11:54:52 UTC

ajax tree

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 
______________________________________________________________________