on 04-15-2008 11:22 PM
Hi,
I've been trying to read an XML file to build a dynamic Table in a Web Dynpro App:
It works but always displays only one record (if I change the code little bit it displays first record otherwise the last record)
I'm not sure what I'm doing wrong and have struggled enough to post it on SDN
I displayed the values from XML fine..just trying to build a dynamic Table now.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<jobs>
<job>
<id>1</id>
<desc>Test</desc>
</job>
<job>
<id>2</id>
<desc>Test2</desc>
</job>
</jobs>
IWDNodeInfo nodeInfo=wdContext.getNodeInfo().addChild("XMLTable", null, true, true, true, false, false, true, null, null, null);
nodeInfo.addAttribute("ID", "com.sap.dictionary.string");
nodeInfo.addAttribute("Desc", "com.sap.dictionary.string");
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("XMLTable", IWDNode.LEAD_SELECTION);
IWDNodeElement nodeElem = node.createElement();
for (int s = 0; s < nodeLst.getLength(); s++)
{
-----condition that loops twice------
nodeElem.setAttributeValue("ID", ((Node) fstNm.item(0)).getNodeValue());
nodeElem.setAttributeValue("Desc", ((Node) lstNm.item(0)).getNodeValue());
node.addElement(nodeElem);
}
My table only shows one row no matter what.
Any idea?
Regards,
E.
Hi
try this,
IWDNodeElement nodeElem = null;
for (int s = 0; s < nodeLst.getLength(); s++)
{
-
condition that loops twice------
nodeElem.createElement();
nodeElem.setAttributeValue("ID", ((Node) fstNm.item(0)).getNodeValue());
nodeElem.setAttributeValue("Desc", ((Node) lstNm.item(0)).getNodeValue());
node.addElement(nodeElem);
}
Regards
Mandeep Virk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Explorer,
move IWDNodeElement nodeElem = node.createElement(); into for loop i.e.
IWDNodeInfo nodeInfo=wdContext.getNodeInfo().addChild("XMLTable", null, true, true, true, false, false, true, null, null, null);
nodeInfo.addAttribute("ID", "com.sap.dictionary.string");
nodeInfo.addAttribute("Desc", "com.sap.dictionary.string");
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("XMLTable", IWDNode.LEAD_SELECTION);
for (int s = 0; s < nodeLst.getLength(); s++)
{
-----condition that loops twice------
// create a new element everytime and add data into it IWDNodeElement nodeElem = node.createElement();
nodeElem.setAttributeValue("ID", ((Node) fstNm.item(0)).getNodeValue());
nodeElem.setAttributeValue("Desc", ((Node) lstNm.item(0)).getNodeValue());
node.addElement(nodeElem);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Thanks for responding. I've tried all that before. Didn't work. Suddenly, this morning when I just moved the create statement inside the for loop..it started working. I swear to god I've tried this before
Anyways, I've noticed this strange behavior with Java Engine or NWDS earlier in a couple of ocassions where the app didn't work one day but when deployed the same package next morning (with out making any changes) it worked..amazing ..
Thanks for helping..
Regards,
E.
Move the createElement() inside the loop.
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 |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.