cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with tutorial: "Creating a Web Dynpro Tree"

Former Member
0 Kudos

Hi!

I'm a rookie and therefore I'm practicing on compleating some tutorials like "Creating a Web Dynpro Tree" (https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0ec6622-8da5-2a10-349b-868b6a553efa)

I did just as the tutorial told me to (I think) but still I get a java.lang.NullPointerException when I deploy and run my application.

In the bold line is where it is something wrong:

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

{

//@@begin wdDoModifyView

if (firstTime) {

IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TreeNodeType");

/* parameter mapping from parameter "path" to

  • parameter "selectedElement"

*/

treeNode._mappingOfOnAction()._addSourceMapping("path", "selectedElement");

/* parameter mapping from parameter "path" to

  • parameter "element".

*/

treeNode._mappingOfOnLoadChildren()._addSourceMapping("path","element");

}

//@@end

}

What I don't understand is what the function/meaning of the parameter path is. The parameters selectedElement and element I do recognize and have written. And I don't understand why there is a difference between the two underscored line of code (see above) even though the comments claim that it does the same kind of mapping.

Best regards

/Johan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I never saw a method named "_addSourceMapping()".

Verify that the TreeNodeType instance has exactly the same ID (case-sensitive) than given in the string literal. The "path" parameter will give you the context path describing the tree node. Alternatively you can use the (implicit) parameter named "nodeElement".

Armin

Former Member
0 Kudos

I tried to get "addSourceMapping()." underscored so people would better understand what I was referring to but it didn't work and that's why it looked weired.

Thanks for your help Armin, now it works fine.

It was as you said.

if (firstTime) {

IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TreeNodeType");

When I changed "TreeNodeType" to it's real ID, "TheNode" I didn't get a nullPointerException. I think it must be wrong in the tutorial because I followed the instructions which said to name it "TheNode" but then the author mus have forgot to change it from the default ID ("TreeNodeType").

Best Regards!

/Johan

Former Member
0 Kudos

I don't know which version you are using, but if available, better use the "Parameter Mapping" editor (Right-click UI element in "Outline") than the old hack in wdDoModifyView(). This avoids those issues with using string literals.

Armin

Former Member
0 Kudos

I'm using Web Dynpro Java in SAP NetWeaver 7.1, so I guess that option is available to me.

Thanks for the tip, to bad I can't give you anymore points 😄

/Johan

Answers (1)

Answers (1)

Former Member
0 Kudos

[clarification to message above]

if (firstTime) {

IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TreeNodeType");

/* parameter mapping from parameter "path" to

  • parameter "selectedElement"

*/

treeNode.mappingOfOnAction().addSourceMapping("path", "selectedElement");

/* parameter mapping from parameter "path" to

  • parameter "element".

*/

treeNode.mappingOfOnLoadChildren().addSourceMapping("path","element");

}

The bold pieces of code is, according to the comments, supposed to do the same kind of mapping even though there is a difference between them other than the parameter names.