Skip to Content
author's profile photo Former Member
Former Member

Node Hierarchy and Error Behaviour

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2005 at 01:38 PM

    according to armin and krish, i suppose i misunderstood the example in the webdynpro book, i am reading - apparently the illustration of the context is merely an image to understand what the author is trying to create in the coding. so, ok, i have got double entries which lead to the exception.

    I don't get this exception when deleting the Date node in the context tab (design time?).

    But then I don't know how to bind the data to a textview created in the layout - maybe some more coding required for that aim?

    regards, matthias

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Armin et al,

      your post before was the decisive hint - I just did not care about the properties of the value node (in the context editor). Now I changed the cardinality from standard 0...n to 1...n! I dropped the whole context runtime-coding and did it all in the context editor.

      The trouble was, that I didn't realize, the standard properties of context nodes (cardinality) lead towards Null Pointer Exception.

      Thank you again, and all the other contributors 😉,

      Matthias

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2005 at 12:56 PM

    Question: Why do you create context nodes at runtime and not at design time?

    Node names must be unique across a context.

    Armin

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Kasig,

      I guess you have not instantiated your node. write following coding in your view's init method.

      iprivate.idate ele = wdcontext.createdateElement();

      wdcontext.nodeDate().bind(ele);

      Add this code and then check once again.

      Regards,

      Bhavik

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2005 at 12:58 PM

    I Think Asfar as The Error is concerned

    There is already a Node Named Date which u r trying to create i suppose

    So just check that

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.