cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Error while Creating Context at RunTime

dhruv_shah3
Active Contributor
0 Kudos

Hi All,

I am creating the Value Node and Value Attribute at Runtime, but i am getting Error of nullpointerException.....

Following is the code Snipet:

public void wdDoInit()

{

//@@begin wdDoInit()

IWDNodeInfo rootnodeInfo = wdContext.getNodeInfo();

IWDNodeInfo soNodeInfo = rootnodeInfo.addChild(

"SalesOrders",

null,

true,

false,true,

false,false,

true,

null,

null,

null);

soNodeInfo.addAttribute("OrderNo","ddic:com.sap.dictionary.integer");

soNodeInfo.addAttribute("SalesDate","ddic:com.sap.dictionary.date");

soNodeInfo.addAttribute("SalesRep","ddic:com.sap.dictionary.string");

soNodeInfo.addAttribute("LongText","ddic:com.sap.dictionary.string");

IWDNode soNode = wdContext.getChildNode("SalesOrder",0);

IWDNodeElement soElement = soNode.createElement();

soElement.setAttributeValue("OrderNo",new Integer(100));

soElement.setAttributeValue("SalesDate",new Date(System.currentTimeMillis()));

soElement.setAttributeValue("SalesRep","Dhruv Shah");

soElement.setAttributeValue("Long Text","Printer Supplies");

soNode.addElement(soElement);

//@@end

}

public static void wdDoModifyView(IPrivateMainView wdThis, IPrivateMainView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if(firstTime)

{

IWDTransparentContainer rootElement = (IWDTransparentContainer) view.getRootElement();

rootElement.createLayout(IWDMatrixLayout.class);

IWDNodeInfo soNodeInfo = wdContext.getChildNode("SalesOrders", 0).getNodeInfo();

for(Iterator iter = soNodeInfo.iterateAttributes(); iter.hasNext();)

{

IWDAttributeInfo soAttrInfo = (IWDAttributeInfo)iter.next();

IWDLabel label = (IWDLabel)view.createElement(IWDLabel.class,soAttrInfo.getName() + "Label");

label.setText(soAttrInfo.getName());

label.createLayoutData(IWDMatrixHeadData.class);

label.setDesign(WDLabelDesign.LIGHT);

label.setLabelFor(soAttrInfo.getName()+ "Input");

rootElement.addChild(label);

IWDInputField ioField = (IWDInputField) view.createElement(IWDInputField.class,soAttrInfo.getName()+"Input");

ioField.createLayoutData(IWDMatrixData.class);

ioField.bindValue(soAttrInfo);

rootElement.addChild(ioField);

}

}

//@@end

}

So can anybody help me out......

Regards,

Dhruv Shah

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

before this IWDNodeElement soElement = soNode.createElement(); line

check soNode is null

Pl post the entire stack.

Regards

Ayyapparaj