on 09-07-2005 10:19 PM
Hi,
I have 5 elements which I need to read from a URL. I get these 5 elements in the Interface Controller and pass them to a function (Initialise) in the Controller.
In the Controller Context I have created a node (ABC) and have 5 Value attributes to this node.
In my Controller function(Initialise), I am trying to set the values in the node as follows:
wdContext.currentABCElement().setElem1( "123");
wdContext.currentABCElement().setElem2( "abc");
wdContext.currentABCElement().setElem3( "xyz");
wdContext.currentABCElement().setElem4( "hij");
wdContext.currentABCElement().setElem5( "klm");
In my wdInit() of the controller I am trying to retrieve the values in the node using the following:
wdContext.nodeABC().currentABCElemen().getElem1();
It throws me a null Pointer Exception, any thougths as to what may be the problem. Any help would be appreciated.
~NAC
Hi,
Please refer this link http://help.sap.com/saphelp_nw04/helpdata/en/d6/078aa26b73fb47b43d9330f1a207cf/content.htm
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What's the cardinality of the node? If it's 0..n (meaning you're going to store a collection), then there is no backing storage in the context to store your data. In this case, you need to allocate and populate the node:
IABCElement elt = wdContext.createABCElement();
elt.setElem1( "abc" );
...
You might want to consider using a supply function, which is defined at the node level in your context. The runtime will automatically call your supply function to populate the context - you would fetch your URL information, create the node as above, and then just go
node.addElement( elt );
If you want to store a single item, change the cardinality to 1:1, and then just access the node - it should already be there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Whatever you are doing is fine.
But, problem is due to initialization of node.
I guess you have set cardinality of your node to "0..N". So, there are two options:
change cardinality to "1..N" or write initialization code in the wdinit method of the controller.
Code is :
ipublic<controllername>.i<node name>element ele = wdcontext.create<node name>element();
wdcontext.node<node name>().bind(ele);
It will initialize your code.
Then you can set values and later on retrieve the values.
Regards,
Bhavik
A supply function is called by the Web Dynpro runtime to populate a context node. On your context node (the one that will contain your data - either in your model, or controller), right click and select 'Properties'. There should be an entry in the properties list for 'Supply Function' - use this entry to define a supply function.
You then manualy create and add elements to the passed in 'node' object.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.