Skip to Content
0
Former Member
Jun 06, 2005 at 12:52 PM

Node Hierarchy and Error Behaviour

18 Views

hi,

when in the root context I create a string value attribute which is being fed with any data, and this context attribute being assigned for example to a textview, then everything is fine, when coding

wdContext.currentContextElement.get....

When I try to organize my attributes in value nodes I get Null Pointer exceptions. Why is that?

According to an example I found, I tried this code (having created a context node Date with attributes strDate, strTime):

	IWDNodeInfo rootNodeInfo = wdContext.getNodeInfo();
	  
		 IWDNodeInfo DatumInfo = rootNodeInfo.addChild(
		   "Date", 
		   null, 
		   true, 
		   false, true, 
		   false, false, 
		   false, 
		   null, 
		   null, 
		   null);
// add Attribute metadata to new node info object		   
		   DatumInfo.addAttribute("strDate", "ddic:com.sap.dictionary.string");
		   DatumInfo.addAttribute("strTime", "ddic:com.sap.dictionary.string"); 	
// create new ContNode using the metadata we just created
		  IWDNode DatNode = wdContext.getChildNode("Date",0);
// create New Elements
			IWDNodeElement eDate = DatNode.createElement();
			IWDNodeElement eTime = DatNode.createElement();
			eDate.setAttributeValue("strDate", "Datum: "+strDatValue);
			eTime.setAttributeValue("strTime", "Uhrzeit: "+strUhrValue);
			
			DatNode.addElement(eDate);
			DatNode.addElement(eTime);

which in turn delivers this:

<i>Error stacktrace:

com.sap.tc.webdynpro.progmodel.context.ContextException: NodeInfo(Step5): duplicate name for child node Date

at com.sap.tc.webdynpro.progmodel.context.NodeInfo.addItem(NodeInfo.java:347)

</i>

Of course I created in the context a Node called "Date", and attributes strDate and strTime. strDatValue is filled beforehand with the actual date.

any hint appreciated,

regards, matthias