Skip to Content

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

Problems with WebDynpro Application

Hello experts,

I have a big problem with my WebDynprot application.

I want to create a tree which shoul hold a company-structure like

CompanyName->Department->Area-Employee.

I have created a medthod called createTestdaten() which shall generate some testdata.

Here the source code:

public void createTestdaten( )

{

//@@begin createTestdaten()

wdContext.nodeOrg_Struktur().getElementAt(0);

IOrg_StrukturNode myOrgNode = wdContext.nodeOrg_Struktur();

IOrg_StrukturElement myRootElement = myOrgNode.createOrg_StrukturElement();

myRootElement.setAbteilung("Companyname");

myRootElement.setParentId("0000");

myRootElement.setObjId("1000");

myRootElement.setHasChildren(true);

myRootElement.setIgnoreAction(false);

myRootElement.setIsExpanded(true);

myOrgNode.addElement(myRootElement);

IOrg_StrukturElement myOrgElement2 = myOrgNode.createOrg_StrukturElement();

myOrgElement2.setAbteilung("TIS");

myOrgElement2.setParentId("1000");

myOrgElement2.setObjId("1100");

myOrgElement2.setHasChildren(true);

myOrgElement2.setIgnoreAction(false);

myOrgElement2.setIsExpanded(false);

myOrgNode.addElement(myOrgElement2);

IOrg_StrukturElement myOrgElement3 = myOrgNode.createOrg_StrukturElement();

myOrgElement3.setAbteilung("PCS");

myOrgElement3.setParentId("1100");

myOrgElement3.setObjId("1120");

myOrgElement3.setHasChildren(true);

myOrgElement3.setIgnoreAction(false);

myOrgElement3.setIsExpanded(false);

myOrgNode.addElement(myOrgElement3);

IOrg_StrukturElement myOrgElement4 = myOrgNode.createOrg_StrukturElement();

myOrgElement4.setAbteilung("Employee 1");

myOrgElement4.setParentId("1120");

myOrgElement4.setObjId("1121");

myOrgElement4.setHasChildren(false);

myOrgElement4.setIgnoreAction(true);

myOrgElement4.setIsExpanded(false);

myOrgNode.addElement(myOrgElement4);

//@@end

}

After the creation of the Testdata I call a method SetRootId:

private void setRootID(){

//rootID setzen

if(wdContext.nodeOrg_Struktur().size()>0)

{

IOrg_StrukturElement myRootElem = (IOrg_StrukturElement) wdContext.nodeOrg_Struktur().getOrg_StrukturElementAt(0);

wdContext.nodeSingle_Node().currentSingle_NodeElement().setRootId(myRootElem.getObjId());

wdContext.nodeSingle_Node().currentSingle_NodeElement().setAbteilung(myRootElem.getAbteilung());

..........

Both Methods are called from the WdDoInit() of the Controller.

The Layout of my View Contains Treestructure element:

The Problem is that it seems that someting is wrong with my addChildren Method.

Here the Code:

public void addChildren( mhp.de.tutorials.wd.mhp_org.wdp.IPrivateOrgView.IOrg_TreeElement element )

{

//@@begin addChildren()

String parentId = element.getParentId();

wdContext.nodeOrg_Tree().invalidate();

IOrg_TreeNode myOrgNode = wdContext.nodeOrg_Tree();

int size = wdThis.wdGetOrgcompController().wdGetContext().nodeOrg_Struktur().size();

for(int i=0; i<size;i++){

IOrg_StrukturElement myTableElem = (IOrg_StrukturElement)wdContext.nodeOrg_Struktur().getElementAt(i);

if(myTableElem.getParentId().equalsIgnoreCase(parentId)){

IOrg_TreeElement myOrgElement = myOrgNode.createOrg_TreeElement();

myOrgElement.setAbteilung(myTableElem.getAbteilung());

myOrgElement.setObjId(myTableElem.getObjId());

myOrgElement.setParentId(parentId);

myOrgElement.setHasChildren(myTableElem.getHasChildren());

myOrgElement.setIgnoreAction(myTableElem.getIgnoreAction());

myOrgElement.setIsExpanded(myTableElem.getIsExpanded());

myOrgNode.addElement(myOrgElement);

}

}

//@@end

}

It seems that something is wrong with my if clause. At Runtime appears a nullPointerException.

Could someone please help me with that project.

Many thanks!!!

Regards Marco

Edited by: Marco Gennari on Oct 2, 2008 12:39 PM

replied

Hi,

Looks like u are using a recursive node

for ur child node

in this case make sure that u have binded the repeated node property of the recursive node(child node) to the parent.

Regards,

Satya.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question