cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic View Context Attribute

Former Member
0 Kudos

Hello All,

How do i create an Attribute to the dynamically created Node ?

I tried using code:

IWDAttributeInfo fieldName = myNode.addAttribute("Attr0",

"com.sap.dictionary.string");

But not sure whether it creates Attribute of AttributeInfo ..

Please explain IWDAttribute.

Regards,

Aayush

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Extending my example from another your post:


/* You are creating metadata */
final IWDNodeInfo niEmployees 
  = wdContext.getNodeInfo().addChild("Employees", /*..*/);
/* Attribute info is metadata as well */
final IWDAttributeInfo aiName 
  = niEmployees.addAttribute("Name", "com.sap.dictionary.string");
/* Now you are accessing data */
/* First node -- "list" of elements */
final IWDNode nEmployees = wdContext.getChild
(
  niEmployees.getName(), /* or "Employees" */
  IWDNode.LEAD_SELECTION
);
/* Then element */
final IWDNodeElement elEmployee = nEmployees.createElement();
/* Now attribute(s) of element */
elEmployee.setAttributeValue
(
  aiName.getName(), /* or "Name" */
  "Aayush Dubey"
); 
nEmployees.addElement(elEmployee);

VS

Former Member
0 Kudos

Thanks VS,

This solves the problem.

Regards,

Aayush

Former Member
0 Kudos

Hello VS,

I tried using the dynamic context in wdDoModify method as:

IWDTextView myTxtView= (IWDTextView) view.getElement("DefaultTextView");

IWDAttributeInfo nInfo = wdContext.getChildNode("Employees",0).getNodeInfo().getAttribute("Name");

myTxtView.bindText(nInfo);

Here the view contained DefaultTextView. It works

Thanks & Regards,

Aayush

Message was edited by: Aayush Dubey

Former Member
0 Kudos

Example: Attribute A in node X


IWDInputField field = (IWDInputField) view.getElement("field");
IWDAttributeInfo att = 
  wdContext
  .getChildNode("X", IWDNode.LEAD_SELECTION).getNodeInfo()
  .getAttribute("A");
field.bindValue(att);

Armin

Message was edited by: Armin Reichert

Former Member
0 Kudos

When perform dynamic binding to UI element you have to work with metadata (*Info) objects.

So it should looks like: (wdDoModifyView)


if (!firstTime) return;
final IWDAttributeInfo aiName 
 = wdContext.getNodeInfo()
     .getChild("Employees")
       .getAttribute("Name");

final IWDInputField editor = (IWDInputField)
  view.createElement(IWDInputField.class, null);
((IWDUIElementContainer)view.getRootElement())
  .addChild(editor);
/* Or get existing view element instead of above */
editor.bindValue(aiName);

VS

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can always verify this by using the statement

wdContext.getNodeInfo().getChild("").getAttribute("Name");

Regards, Anilkumar

Former Member
0 Kudos

Hi,

Your code creates a context attribute to a Context node. It returns an object of IWDAttributeInfo I suppose.

The IWDAttribute is an interface for the WebDynpro Context Attribute.

Hope MyNode is of type IWDNodeInfo.