on 05-19-2005 8:59 PM
Trying to create nodes dynamically. Node heirarchy is as follows
RootNode
---C100 (parent node)
-
Division (child node)
-
DivisionSet (child-child node)
All nodes are created at runtime. Except C100, all node elements are dependent non-singletons
When I execute I get a 'Null point exception' at line marked with ####, when trying to create IWDNodeElement nodeElem
Code is as follows..................................
IWDNodeInfo salesOrgs = wdContext.nodeSalesOrgs().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild("C100",null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild("Division",null,false,true,true,false,false,true,null,null,null);
salesOrg.addAttribute("defaultValue","ddic:com.sap.dictionary.string");
salesOrg.addAttribute("labelValue","ddic:com.sap.dictionary.string");
salesOrgElement.addChild("Division"+"Set",null,false,true,true,false,false,true,null,null,null);
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("Division",2);
IWDNodeElement nodeElem = node.createElement(); //##### - Problem here
nodeElem.setAttributeValue("defaultValue","");
nodeElem.setAttributeValue("labelValue","");
node.addElement(nodeElem);
//@@end
}
Do let me know how to recrify.
Thanks !
Sri
Actually, the problem is one line above:
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("Division",2);
You are trying to get 3d element of root node and then get its direct child division. Root node has only one instance. Therefor you should use
IWDNode node100 = wdContext.wdGetAPI().getRootNode().getChildNode("C100",0);
if (node100.size > 0) /* or whatever <b>element</b> index you refer */
IWDNode nodeDivision = node100.getChildNode("Division", 0);
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kindly check if this is what you required.
You were trying to create an element of Division node and then setting the attribute. The attribute that you have created is under C100.
IWDNodeInfo salesOrgs = wdContext.nodeSalesOrgs().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild("C100",null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild("Division",null,false,true,true,false,false,true,null,null,null);
salesOrg.addAttribute("defaultValue","ddic:com.sap.dictionary.string");
salesOrg.addAttribute("labelValue","ddic:com.sap.dictionary.string");
salesOrgElement.addChild("Division"+"Set",null,false,true,true,false,false,true,null,null,null);
IWDNode node=wdContext.nodeSalesOrgs().getChildNode("C100",IWDNode.LEAD_SELECTION);
IWDNodeElement nodeElem=node.createElement();
nodeElem.setAttributeValue("defaultValue","");
nodeElem.setAttributeValue("labelValue","");
Noufal,
Think we are getting close to a resolution on this. Your code worked to perfection.
Need to tweak this code such that the attributes are created under Division node and not under C100. That is the 'defaultValue' and 'labelValue' attributes are elements of Division node. DivisionSet node is also an element of Division.
Tried some modifications to the code, but still get Null pointer exception. Code is listed below. Advise what I have coded wrongly.
IWDNodeInfo salesOrgs = wdContext.nodeSalesOrgs().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild("C100",null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild("Division",null,false,true,true,false,false,true,null,null,null);
salesOrgElement.addAttribute("defaultValue","ddic:com.sap.dictionary.string");
salesOrgElement.addAttribute("labelValue","ddic:com.sap.dictionary.string");
salesOrgElement.addChild("Division"+"Set",null,false,true,true,false,false,true,null,null,null);
IWDNode node=wdContext.getChildNode("Division",0);
IWDNodeElement nodeElem=node.createElement();
nodeElem.setAttributeValue("defaultValue","");
nodeElem.setAttributeValue("labelValue","");
Also, do I use 'bind' or 'addElement' to update 'node' with the new attribute values.
Please advise!
Sri
Guys,
Looks like I am close to resolving this issue. However, still get the message listed below.
"Node(PopulateListView.SalesOrgs.C100.Division): cannot bind or add elements because the node has no valid parent"
I have listed the moded code for your reference. Seem to run into problem when adding the element to the node (last line of code). Do let me know what needs to be done to resolve this.
IWDNodeInfo salesOrgs = wdContext.nodeSalesOrgs().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild("C100",null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild("Division",null,true,true,true,false,false,true,null,null,null);
salesOrgElement.addAttribute("defaultValue","ddic:com.sap.dictionary.string");
salesOrgElement.addChild("Division"+"Set",null,true,true,true,false,false,true,null,null,null);
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("SalesOrgs",0);
IWDNode node100 = node.getChildNode("C100",IWDNode.LEAD_SELECTION);
IWDNode node200 = node100.getChildNode("Division",IWDNode.LEAD_SELECTION);
IWDNodeElement nodeElem=node200.createElement();
nodeElem.setAttributeValue("defaultValue","1");
node200.addElement(nodeElem);
Thanks !
Sri
Hi,
Here is your code..
IPrivateDynAppView.ISalesOrgsElement ele=wdContext.createSalesOrgsElement();
wdContext.nodeSalesOrgs().addElement(ele);
IWDNodeInfo salesOrgs = wdContext.nodeSalesOrgs().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild("C100",null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild("Division",null,false,true,true,false,false,true,null,null,null);
salesOrgElement.addAttribute("defaultValue","ddic:com.sap.dictionary.string");
salesOrgElement.addAttribute("labelValue","ddic:com.sap.dictionary.string");
salesOrgElement.addChild("Division"+"Set",null,false,true,true,false,false,true,null,null,null);
IWDNode node=wdContext.nodeSalesOrgs().getChildNode("C100",IWDNode.LEAD_SELECTION);
IWDNodeElement elem=node.createElement();
node.addElement(elem);
IWDNode divNode=wdContext.nodeSalesOrgs().getChildNode("C100",IWDNode.LEAD_SELECTION).getChildNode("Division",0);
IWDNodeElement element=divNode.createElement();
divNode.addElement(element);
element.setAttributeValue("defaultValue","Text");
String text=wdContext.nodeSalesOrgs().getChildNode("C100",IWDNode.LEAD_SELECTION).getChildNode("Division",0).getElementAt(0).getAttributeAsText("defaultValue");
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(text);
Hope this is what you required...
Regards
Noufal
Message was edited by: Noufal Kareem
According to your context structure, "Division" is not child node of the root node.
Try this:
wdContext
.getChildNode("C100", IWDNode.LEAD_SELECTION)
.getChildNode("Division", 2);
Apart from this, where do you create the node elements of "C100"? You try to access the third node element.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.