cancel
Showing results for 
Search instead for 
Did you mean: 

set value in DropDownByKey during runtime

Former Member
0 Kudos

Hello all,

is there a way, to set the valueSet of a DropDownByKey UIElmement during runtime or change the enumeration of a simple type?

I have a RFC function that returns all possible valueSets of the DropDownByKey Element. I create a ContextNode in the Context of the Controller and in the Context of the View and bind them. I also bind the DropDownByKey UIElement (attribute "selectedKey") to a context attribute ("Sysid") of the View Context. Then I create a new method at the controller, that call's the rfc function and invalidate the context after calling the function successfully. I call this method at the doInit Methode of the view as followed...

<u>Coding doInit method of the view:</u>

wdThis.wdGetAccountLockController().callRfcSysteme();

Object attr = wdContext.currentZ_Fh0002_Systeme_OutputElement().getAttributeValue("Sysid");

All the mapping works successfully. I tested this with the second coding line above. So I get the correct value in the attribute "Sysid", but there is no value in the DropDownByKey UIElement. How can I set the value of the context attribute "Sysid" to the attribute "selectedKey" of the DropDownByKey UIElement?

Can anyone help my, please?

Best regards

Petra

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Petra,

just giving you a few lines of code as example. I am populating a DropDownByKey UI Element dynamically here.. though the data is hardcoded in my case.. it will come from backend in your case.

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("");

ISimpleTypeModifiable countryType = attributeInfo.getModifiableSimpleType();

countryType.setFieldLabel("Country");

IModifiableSimpleValueSet valueSet = countryType.getSVServices().getModifiableSimpleValueSet();

valueSet.put("DE","Germany");

valueSet.put("GB","Great Britain");

valueSet.put("US","United States");

...

valueSet.put("ALL","All");

wdContext.currentContextElement().setCountry("All");

here Country is a Value Attribute in view context having type property maped with a already created simple type.

You cal also catch the values in the populated set by this code

for (int idx = 0; idx < valueSet.size(); idx++){

Object key = v.getKey(idx);

String text = v.getText(idx);

}

hope this helps...

regards,

Shubhadip

Former Member
0 Kudos

Hi Petra,

sorry a mistake in my code, the first line should be

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("Country");

Former Member
0 Kudos

Petra,

Search your NW help for ISimpleTypeModifiable -- you get references to "Dynamic Metadata", "Code Example of Key Binding" and finally "Inserting an Extended Value Selector" -- I guess this provides you with enough information on modifying value set at run-time.

VS

Former Member
0 Kudos

Petra,

Define a simpleType. Bind it to a context attribute.Bind that attribute to the dropdown box. Say the name of attributw value is dropDown.

get an IwdattributeInfo value.

create a ISimpleTypeModifiable

Create a IModifiableValueSet

then use the modifiable valueset object.put() function to create the dropdown dynamically