cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Tree UI Element - expansion of child nodes

Former Member
0 Kudos

Hi

I'm currently facing the problem where child nodes beyond second level do not expand. The issue lies with the elements not binding to the parent node from which they have been expanded. The various combinations that have tried either resulted one of these:

a) All child elements expanding under the first node.

b) With initial lead selection led to 'false' and on selecting the node first and then clicking expanding, the child elements get filled up in the node, but on clicking the child nodes below it. It starts filling the node which is lead selected.

c) If I expand the tree based on the index of element, it doesn't expand beyond the second level and throws index exception.

Following is the code mentioning :

 public void addChildren( essent.nl.sp.wdp.IPrivateZSPAllSitesStartView.ITreeSiteDirectoryElement element )
  {
    //@@begin addChildren()
	IWDMessageManager manager = wdComponentAPI.getMessageManager(); 
	
//	IPublicZSPAllSitesComp.ITreeSiteDirectoryElement TreeSiteDirectoryElement = element.mappedTreeSiteDirectoryElement();
//	IPublicZSPAllSitesComp.ITreeSiteDirectoryNode TreeSiteDirectoryNode = element.node().getNodeIn;
	IPublicZSPAllSitesComp.ITreeSiteDirectoryNode ChildTreeSiteDirectoryNode = wdContext.nodeTreeSiteDirectory();
	IPublicZSPAllSitesComp.ITreeSiteDirectoryElement ChildTreeSiteDirectoryElement = null;

//	IPublicZSPAllSitesComp.ITreeSiteDirectoryElement InnerChildTreeEle1, InnerChildTreeEle2 = null;
	
	Vector table = new Vector();
	Vector line = null;
	
	try
	{
		String busServer = element.getServer();
//		HashMap hashMapCache = new HashMap();
//		Object oHashMapCache = hashMapCache.get("ZSharepointSites"+busServer);
//		ICacheService cache = (ICacheService)WDPortalUtils.getServiceReference("com.sap.portal.compatibility50.cache");//use of this reference
//		Object vectorcache = cache.get("ZSharePointSites" + busServer);
//		if(oHashMapCache == null)
//			{
			try
			{
				//Execute the URL 
				request.setPortalURL(busServer);
				wdContext.currentGetFullSiteDirectoryElement().modelObject().execute();
				wdContext.nodeResponse().invalidate();
				wdContext.nodeResult().invalidate();
				
				//Obtain the response
				Response_ServiceSoap_getFullSiteDirectory response = request.getResponse();
				ComplexType_GetFullSiteDirectoryResult result = response.getResult();
				Object schema = result.get_any();
				wdContext.currentGetFullSiteDirectoryElement().setPortalURL(schema.toString());
				
				//Parse the XML using DocumentBuilder
				DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
				DocumentBuilder db = dbf.newDocumentBuilder();
				InputSource insrc = new InputSource(new StringReader(schema.toString()));
				Document doc = db.parse(insrc);
				doc.getDocumentElement().normalize();
				
				
				NodeList listOfPersons = doc.getElementsByTagName("Table1");
				int totalPersons = listOfPersons.getLength();
				for(int s = 0; s < listOfPersons.getLength(); s++)
				{
					Node firstPersonNode = listOfPersons.item(s);
					if(firstPersonNode.getNodeType() == 1)
					{
						Element firstPersonElement = (Element)firstPersonNode;
						NodeList ParentIDList = firstPersonElement.getElementsByTagName("ParentID");
						Element ParentIDElement = (Element)ParentIDList.item(0);
						NodeList textParentIDList = ParentIDElement.getChildNodes();
						String strparentid = textParentIDList.item(0).getNodeValue().trim();
						line = new Vector();
						NodeList IDList = firstPersonElement.getElementsByTagName("ID");
						Element IDElement = (Element)IDList.item(0);
						NodeList textIDList = IDElement.getChildNodes();
						NodeList HasChildrenList = firstPersonElement.getElementsByTagName("HasChildren");
						Element HasChildrenElement = (Element)HasChildrenList.item(0);
						NodeList textHasChildrenList = HasChildrenElement.getChildNodes();
						NodeList NameList = firstPersonElement.getElementsByTagName("Name");
						Element NameElement = (Element)NameList.item(0);
						NodeList textNameList = NameElement.getChildNodes();
						NodeList DescriptionList = firstPersonElement.getElementsByTagName("Description");
						Element DescriptionElement = (Element)DescriptionList.item(0);
						NodeList textDescriptionList = DescriptionElement.getChildNodes();
						NodeList URLList = firstPersonElement.getElementsByTagName("URL");
						Element URLElement = (Element)URLList.item(0);
						NodeList textURLList = URLElement.getChildNodes();
						NodeList OwnerList = firstPersonElement.getElementsByTagName("Owner");
						Element OwnerElement = (Element)OwnerList.item(0);
						NodeList textOwnerList = OwnerElement.getChildNodes();
						if(textHasChildrenList.toString().equals("<HasChildren>True</HasChildren>\n\n"))
							{
								line.addElement(String.valueOf("true"));
						} else
						{
							line.addElement(String.valueOf("false"));
						}
						line.addElement(String.valueOf(textNameList.item(0).getNodeValue().trim()));
						line.addElement(String.valueOf(textIDList.item(0).getNodeValue().trim()));
						line.addElement(String.valueOf(textURLList.item(0).getNodeValue().trim()));
						line.addElement(String.valueOf(busServer));
						line.addElement(String.valueOf(textParentIDList.item(0).getNodeValue().trim()));
						table.addElement(line);
						
					}
				}
//				cache.invalidate("ZSharePointSites" + busServer);
//				cache.put("ZSharePointSites" + busServer, table, true);
//				hashMapCache.put("ZSharepointSites"+busServer,table);
			}
			catch(Exception e)
			{
				manager.reportException(e.toString(), false);
			}
//		}
//		else 
//		{
////						table = (Vector)vectorcache;
//						table = (Vector)oHashMapCache;
//		}
		
				int nrofdiv = table.size();
				String linehaschildren = "";
				String lintext = "";
				String lineid = "";
				String lineurl = "";
				String linebusserver = "";
				String lineParentID = "";
					
				int iBranch =0;
				//Filling the node
				for(int i = 0; i < nrofdiv; i++)
					{
					line = (Vector)table.elementAt(i);
					linehaschildren = (String)line.elementAt(0);
					lintext = (String)line.elementAt(1);
					lineid = (String)line.elementAt(2);
					lineurl = (String)line.elementAt(3);
					linebusserver = (String)line.elementAt(4);
					lineParentID = (String)line.elementAt(5);

					if(lineParentID.equals(element.getID()) )
							{
							ChildTreeSiteDirectoryElement = element.mappedTreeSiteDirectoryElement().nodeChildTreeSiteDirectory().createTreeSiteDirectoryElement();
							int lead = element.index(); 
							ChildTreeSiteDirectoryNode.getTreeSiteDirectoryElementAt(lead).nodeChildTreeSiteDirectory().addElement(ChildTreeSiteDirectoryElement);
//							ChildTreeSiteDirectoryNode.addElement(ChildTreeSiteDirectoryElement);
//							ChildTreeSiteDirectoryElement.setIconSource("~sapicons/s_clofol.gif");
							ChildTreeSiteDirectoryElement.setIgnoreAction(true);
							//
							if(linehaschildren.toString() == "true")
							{
								ChildTreeSiteDirectoryElement.setHasChildren(true);
							} else
							{
								ChildTreeSiteDirectoryElement.setHasChildren(false);
							}
							
							//
							if(lintext.length() != 0)
							{
								ChildTreeSiteDirectoryElement.setText(lintext);
							}
							
							if(lineid.length() != 0)
							{
								ChildTreeSiteDirectoryElement.setID(lineid);
							}
							
							if(lineurl.length() != 0)
							{
								ChildTreeSiteDirectoryElement.setURL(lineurl);
							}
							
							ChildTreeSiteDirectoryElement.setServer(linebusserver);
						}
//						
					}
	}
	catch(Exception ex)
	{
		manager.reportException(ex.toString(), false);
	}
	
	
    //@@end
  }

Thanks in advance,

Regards

Srikant

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Resolved on reviewing the code

Former Member
0 Kudos

Hi

go thorugh:[http://help.sap.com/saphelp_nw04/helpdata/en/c2/abfceffbacd24185ec7af8a3a2e76a/frameset.htm]

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0ec6622-8da5-2a10-349b-868b6a553efa]

Regards,

Khushboo

Former Member
0 Kudos

Hi Khushboo,

I've seen these codes, but they are not much of help.

The problem got resolved by reviewing the code.

Regards

Srikant

Edited by: D.V.Srikant on Sep 6, 2008 1:42 PM

Former Member
0 Kudos

Hi Srikant,

I followed the step-by-step which is in NWDS Help, and it worked well. Please search for "Further Procedure for Developing the Web Dynpro Application". It deals with recursive nodes and WD Tables.

Try also this link:

Integration of a Tree Structure in a Web Dynpro Table

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/de59f7c2-0401-0010-f08d-8659cef5...

Regards,

Douglas Frankenberger