cancel
Showing results for 
Search instead for 
Did you mean: 

Attribute path

Former Member
0 Kudos

Hi all,

I need to retrieve the path of an attribute to dynamically map it to a UI element.

How can I get the attribute or the node path without leading window name???

Please help!

Stefano!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
+ MyNode
+ --  MyAttribute

wdContext.nodeMyNode().getNodeInfo().getAttribute(I<Controller>Element.MY_ATTRIBUTE);

Armin

Former Member
0 Kudos

Hi Armin,

I haven't the nodeMyNode() method because the context is created at runtime.

Are u sure that I can use the following statement:


InputField.bindValue(wdContext.nodeMyNode().getNodeInfo().getAttribute(I<Controller>Element.MY_ATTRIBUTE));

The InputField.bindValue() method expect a string with the reference like "MyNode.MyAttribute", does the getAttribute() return this?

thank you again,

Stefano

Former Member
0 Kudos

here is example for text view:

IWDNodeInfo nodeInfo = wdContext.getChildNode("MyNode",IWDNode.LEAD_SELECTION).getNodeInfo();

IWDTextView tvEditor = (IWDTextView) view.createElement(IWDTextView.class, null);

tvEditor.bindText(nodeInfo.getAttribute("<ATTRIBUTE NAME>"));

for the input filed the same.

Former Member
0 Kudos

I've tryed this but it seems it doesn't work.

It seems that the getChildNode() method returns null...

Here is my code:


public void wdDoInit()
{
...
//Create Parent node
  IWDNodeInfo Parent = wdContext.getNodeInfo().addChild("ParentNode",null,true,true,false,false,false,true,null,null,null);
//Create Parent attributes
  Parent.addAttribute("Attr1","com.sap.dictionary.string");
  Parent.addAttribute("Attr2","com.sap.dictionary.string");
//Create child node
  IWDNodeInfo Child = wdContext.getNodeInfo().getChild("ParentNode").addChild("Child",null,true,true,false,false,false,true,null,null,null);
//Create Child attributes
  Child.addAttribute("Attr1","com.sap.dictionary.string");
  Child.addAttribute("Attr2","com.sap.dictionary.string");
...
public static void wdDoModifyView(IPrivateRequestView wdThis, ..., boolean firstTime)
{
  if (firstTime) {
    IWDNodeInfo nodeInfo = wdContext.getChildNode("ChildNode",IWDNode.LEAD_SELECTION).getNodeInfo();
    IWDInputField InputField = (IWDInputField) view.createElement(IWDInputField.class, "InputFieldAttr1"); 
    InputField.bindValue(nodeInfo.getAttribute("Attr1"));
...

Where I'm wrong?

Former Member
0 Kudos

You create the child node with name "Child" and access it with name "ChildNode".

Armin

Former Member
0 Kudos

> You create the child node with name "Child" and

> access it with name "ChildNode".

>

> Armin

Transcription error, it still not working...

Former Member
0 Kudos
    wdContext
      .getChildNode("Parent", IWDNode.LEAD_SELECTION)
      .getChildNode("Child", IWDNode.LEAD_SELECTION).getNodeInfo()
      .getAttribute("Attribute");

Armin

Former Member
0 Kudos

Hi Armin,

my application receive context structure from an adaptive RFC model and build the context accordingly, the code I've inserted is just an example of which instructions I've used to build the context node and subnode.

At runtime I don't know which is the exact context structure because it is builded dynamically, the only thing that I know is the name of the node that contains the attribute that I have to map.

"Child" node could be a subnode of "Parent" or could be a parent itself or moreover the child of a child2... The only thing that I know at runtime is that my node is named "Child" and that it contains my attribute.

Sorry for the misunderstanding. Any suggestions?

monalisa_biswal
Contributor
0 Kudos

Use IterateChildren method to iterate over child nodes

Iterator it =wdContext.getNodeInfo().iterateChildren();

while(it.hasNext())

{

IWDNodeInfo nodeInfo=(IWDNodeInfo)it.next();

wdComponentAPI.getMessageManager().reportSuccess(nodeInfo.getName());

Iterator it1=nodeInfo.iterateChildren();

while(it1.hasNext())

{

IWDNodeInfo nodeInfo1=(IWDNodeInfo)it1.next();

wdComponentAPI.getMessageManager().reportSuccess(nodeInfo1.getName());

}

}

Former Member
0 Kudos

Hi all,

I've solved my problem getting the path with NodeInfo.getPathDescription(), getting a string with the view name and then applying substring() to the path.

Thank u to everybody!

Stefano

Answers (1)

Answers (1)

Former Member
0 Kudos

Armin,

Can you help me sort out this problem?

I created a SearchResults context node in component controller and ResultView controller as well at design time and context mapping them at design time. Now at runtime, I created two attributes and setAttributeValue to this two attributes in component Controller, how can I map these two attributes to ResultView in runtime, so that I can get data and display them on View.

many thanks in advance

Andy