Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Getting Error while Creating Context at RunTime

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

Former Member
Not what you were looking for? View more on this topic or Ask a question