cancel
Showing results for 
Search instead for 
Did you mean: 

Can't set an attribute in Context

Former Member
0 Kudos

Hi WebDyn Pro's,

I have a very basic question I think. I snooped thru several tutorials and sample code and I can't figure out why my code fails. It seems to me that I'm doing nothing different than the sample code.

I have one View in my project. I have a context node named "MyData". In the doInit method of the one View, I have the following code:

<b>wdContext.currentMyDataElement().setName("John"):</b>

This lines throws a nullPointer Exception.

Any ideas?

Thanks

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The context exists in the view, right? Not the controller?

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

When working with Nodes, this is how I usually access the data.

In my context, there is a node called MyNode, under that there is a attribute named UserName.



  public void wdDoInit()
  {
    //@@begin wdDoInit()

	
		IPrivateMain.IMyNodeNode MyNode = wdContext.nodeMyNode();
		IPrivateMain.IMyNodeElement MyElm;

		MyElm = MyNode.createMyNodeElement();

		MyElm.setUserName("Rich Heilman");

		MyNode.addElement(MyElm);


    //@@end
  }



This works for me.

Regards,

Rich Heilman

Answers (0)