cancel
Showing results for 
Search instead for 
Did you mean: 

Static and Dynamic Context

former_member187439
Active Participant
0 Kudos

Question 1. I have created a static value node say vn_static. At run time, based on some condition i want to add dynamic value attributes say va_dynamic1, va_dynamic 2 etcs... What is the code to create a dynamic value attribute to my static value node?

Question 2. I have a drop down list that i created dynamically based on the Function module's output as shown in below code. Now user selects a value from this drop down list and i want to retrieve that user selected value from the drop down on button action. What is the code to retrieve the value?

 IWDNodeInfo rootNodeInfo = wdContext.getNodeInfo();
					IWDNodeInfo configNodeInfo =
						wdContext.getNodeInfo().addChild(
							"vn_DynamicDDnode" + firstLoop,
							null,
							true,
							true,
							false,
							false,
							false,
							true,
							null,
							null,
							null);
					configNodeInfo.addAttribute(
						"va_config",
						"ddic:com.sap.dictionary.string");
					IWDNode configNode =
						wdContext.getChildNode(
							"vn_DynamicDDnode" + firstLoop,
							0);
					IWDNodeElement configElement = configNode.createElement();
					configElement.setAttributeValue("va_config", new String());
					configNode.addElement(configElement);
					IWDDropDownByKey iwdDD1 =
						(IWDDropDownByKey) view.createElement(
							IWDDropDownByKey.class,
							null);
					ISimpleTypeModifiable config =
						wdThis.wdGetAPI().getContext().getModifiableTypeOf(
							"vn_DynamicDDnode" + firstLoop + ".va_config");
					IModifiableSimpleValueSet configValues =
						config.getSVServices().getModifiableSimpleValueSet();
					configValues.put("", "");}

Appropriate answer to either 1 or both the questions will be rewarded with maximum points.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

1. To add dynamic value attribute to your static node, use the following code

wdContext.node<staticnode>().getNodeInfo().addAttribute(<name>,<type>);

2. For getting the value of the current selected element of dynamic node

wdContext.getChildNode(<dynamic node name>,IWDNode.LEAD_SELECTION).getCurrentElement().getAttributeAsText(<attribute name>);

Regards,

Murtuza

former_member187439
Active Participant
0 Kudos

Hi Murtuza, I'm getting "Type not found exception" when i try adding dynamic attribute to static node.

		wdContext.nodeVnMaterialConfiguration().getNodeInfo().addAttribute("va"+wdContext
					.nodeConfigChar_Val_Tab()
					.getConfigChar_Val_TabElementAt(firstLoop)
					.getAtnam(), new String());

Former Member
0 Kudos

Kavitha,

For the Type not found exception, you sholud be mentioning the DDIC type as string, and not the Java String object.

Regards,

Alka.

Former Member
0 Kudos

Hi,

The type of the newly created attribute should be "ddic:com.sap.String".

Regards,

Murtuza

former_member187439
Active Participant
0 Kudos

Murtuza - Thank you.Your both answers are appropriate and i rewarded points.

Thanks to others for responding.

Armin - Yes, my requirement has no other solution other than using dynamic UI s and dynamic contexts.

Former Member
0 Kudos

Really? I have often seen such questions here where creating context structures by code would not have been necessary.

Armin

Answers (5)

Answers (5)

former_member187439
Active Participant
0 Kudos

Hi Murtuza,

How to set a particular value as lead selected in the dynamic drop down?

Example: Dynamic drop down node name is vn_dd and value attribute name is va1. Say, va1 contains four values a,b,c,d. Now, during an action and condition i want to set va1's lead selected value as "c". How to do that in dynamic node?

In static node, normally it works just by setting current element (drop down by key).

Thanks & Regards.

former_member187439
Active Participant
0 Kudos

How to set lead selection as 0 for a dynamically created node?

The below code is not working.

                        wdContext
				.getChildNode(
					wdContext
						.nodeVn_ddNodeAttrNames()
						.getVn_ddNodeAttrNamesElementAt(size)
						.getVa_DDnodeName(),
					IWDNode.LEAD_SELECTION)
				.setLeadSelection(0); 

Former Member
0 Kudos

HI,

It should be

wdContext.getChildNode(<nodename>,IWDNode.LEAD_SELECTION)

.setLeadSelection(0);

Regards,

Murtuza

former_member187439
Active Participant
0 Kudos

That is not working... (setting lead selection to zero)

Former Member
0 Kudos

And my question to you: Is it really necessary to create context structures and UI elements programmatically? Maybe we can solve that much more easily.

Could you please describe the use-case in more detail?

Armin

Former Member
0 Kudos

Hi Kavitha,

Follow these steps for your first question,

1) Get access to your static node and add the attributes like this,


IWDNode <nodeName> = wdContext.getChildNode("<yourNodeName>", 0);
IWDNodeInfo <nodeInfo> = <nodeName>.getNodeInfo();
<nodeInfo>.addAttribute(<attrName>,<attrType>);

Regards

Kishan

Former Member
0 Kudos

Hi,

Question 2 answer

you write this code in button action.

I am retriving that dropdown value and displaying in textbox.

String ss=wdContext.currentContextElement().getObject();

wdContext.currentContextElement().setText(ss);

getObject() means dropdown values.

setText() means displaying that value in textbox.

Regards,

Sunaina Reddy T