on 02-06-2008 5:04 AM
Hi,
I created a node Person. It contains two attributes FName and LName.
In order to access these attributes, I am using
wdContext.currentPersonElement.getFName();
wdContext.currentPersonElement.getLName();
But in a book I saw the followind code to access the attribute
IPersonNode node = wdContext.nodePeople();
IPersonElement ele = node.currentPersonElement();
String fname = ele.getFName();
String fname = ele.getLName();
What is the difference between these two. In which scenarios we use the first one and in which scenarios we use the second one?
Regards
V. Suresh Kumar
The wdContext.current<Node>Element() methods are shortcuts for accessing the "current" element in a node. The current element is defined by following the lead selection from the context root down to the node in the context hierarchy.
If the node is a non-singleton child node of some parent node "Parent", then you probably don't want to follow this lead-selection path but access the node that belongs to some other (not lead-selected) element of "Parent".
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is a mistake in my code
IPersonNode node = wdContext.nodePeople();
IPersonElement ele = node.currentPersonElement();
String fname = ele.getFName();
String fname = ele.getLName();
I had given IPersonNode node = wdContext.nodePeople() previously. Its not People, it is person.
The updated code is as below:
IPersonNode node = wdContext.nodePerson();
IPersonElement ele = node.currentPersonElement();
String fname = ele.getFName();
String fname = ele.getLName();
Regards
V. Suresh Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
IPersonNode node = wdContext.nodePeople();
IPersonElement ele = node.currentPersonElement();
String fname = ele.getFName();
String fname = ele.getLName();
If you closely look at the above code it looks like a recursive node is the context structure.
NodePeople-> NodePerson
IPersonNode node = wdContext.nodePeople(); will have error
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Both are same. If you look clearly, they resolve to same syntax. Second one is more lengthier. That is the only difference. It is like this example.
Apple a = new Apple();
a.setName("Apple");
is same as
new Apple().setName("Apple");
Regards,
Harini S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both are going to return the same in the current scenario.We make use of the
IPersonNode node = wdContext.nodePeople();
IPersonElement ele = node.currentPersonElement();
We make use of the element if e have to bind some 'n' number of records to a node.
where as the
wdContext.currentPersonElement.getFName();
wdContext.currentPersonElement.getLName();
is going to hold the current values of the attributes.(i.e, a single value)
If make use of element we can loop till the size of the node and add 'n' number of records to the node.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Both will return the same values() ie Fname and Lname.
We can use the Second set of statement as single one as first..
or
wdContext.node<NodeName>().current<Node>Element().get<Field>();
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What is your node Structure?Do you have people node directly under the context and person node under the people node?
If so then both the cases which you have mentioned are same.
Both returns the current lead selected element under the people node.If no element is selected then it returns null.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.