Wednesday, October 16, 2013

Programmatically creating dynamic multi levels in hierarchy Viewer Component by ADF Oracle.



I want to share you  to how are deploy  dynamic multi  levels  in  hierarchy Viewer Component  using ArrayList class,you can implement normal  hierarchy Viewer  or tree or treeTable by reading oracle documentation.

Actually the  hierarchy Viewer Component show nodes according to the relation between  tables,so if the relation  between emp and dept table show only tow levels

We depend on arraylist class  in java.util package  to create  dynamtic treemodel which are bounded as value to hierarchyViewer Component , so we can create  mutli parent nodes and mutli child  nodes  as in the below picture.


I deploy one project which show all links in determined URL as tree, i depend on json file jar which fetch html code and get all links and pictures  for URL..

In this issue i create recursive function which fetch all the links in URL and insert every link in one hierarchy Viewer Item object in current arraylist and call same function with first one link from current arraylist as parameter . by this  function i create  multi  array list as tree .


public void Serach(ArrayList parent, String url, int k) 
{ Document docWebSite; 
try { //check if Current URL Vaild 
// limited the Recusive to 3 three 
if ((k == 3) || (!isValidURL(url))) 
return; 
//fetch current web site as data 
docWebSite = Jsoup.connect(url).get(); 
// get all links 
Elements links = docWebSite.select("a[href]"); 
for (Element link : links) { 
hierarchyViewerItem node1 = 
new hierarchyViewerItem(link.text(), link.attr("href"), 
docWebSite.body().html()); 
parent.add(node1); 
ArrayList node1Children = 
new ArrayList(); 
node1.setChildren(node1Children); 
// Recusive Function 
Serach(node1Children, link.attr("href"), k + 1); 
} catch (IOException e) { 
e.printStackTrace(); 





Th project show the URL links in hierarchy Viewer Component ,every link represents one node. also show all images in URL  in carousel Component.





The sample can be downloaded from 
             1.ADF Project.
             2.JSoup jar file.
            


To impove this project , we need add image Component  in  hierarchy Viewer Component  which has web page as picture not html code , so  if anyone has experince how we convert web page to picture in ADF , you can write his comments about that.



Regards
Sameer.alwosaby

















   

No comments:

Post a Comment