cancel
Showing results for 
Search instead for 
Did you mean: 

not getting value from DropDownByKey

Former Member
0 Kudos

Hi

I have a drop down by key and assigned a simple type to it and have 4 options in that simple type. and i bound that DropDownByKey element to a model attribute but i am not getting any value in that attribure i have not written any code to get selected value do i need to write it or automaticaly i will get it

Thanks

Ninad

Accepted Solutions (0)

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi Ninad,

If you want to show static values in your DropDownByKey take simple type. And make your context variable to type of that simple type. and add this variable to your Drop Down by key control.

If you want to show model values in your DropDown use below code.

IContextElement contextElement = wdContext.currentContextElement();

IWDNodeInfo nodeInfo = wdContext.getNodeInfo();

IWDAttributeInfo dateAttributeInfo = nodeInfo.getAttribute(contextElement.empCode);

IModifiableSimpleValueSet dropValueSet = dateAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

String empCodeTxt=null;

//Gives the Size of the List, which is coming from Model

int nodeLength = wdContext.node<BAPIList>().size();

for (int i = 0; i < nodeLength; i++) {

// Gives the Value, Which you want to show in Drop Down List Box.. Change it according to your need.

empCodeTxt=String.valueOf(((IPrivate<viewname>.I<BAPIList>Element)(wdContext.node<BAPIList>().getElementAt(i))).get<Parameter>());

dropValueSet.put(empCodeTxt, empCodeTxt);

}

Hope you understand this.

Regards,

Sridhar

Former Member
0 Kudos

Do you mean that when the user selects a value from the DropDownByKey, the value is not set in the corresponding context attribute? You should not have to write code to set the value.

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Ninad,

You can get the current selection by the statement:

String selected_key = wdContext.currentContextElement().get<your_attribute_name>();

This will return you key value;

To get the corresponding text for the key, use the following code:

String attributeName = IPrivate<your_view>View.IContextElement.<your_simpletype_attribute>;

IWDAttributeInfo attributeInfo = wdThis.wdGetContext().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

ISimpleValueSet valueset = simpleType.getSVServices().getValues();

if(null!=selected_key)

String text_value = valueset.getText(selected_key);

'text_value' will have the corresponding text.

Hope this helps you,

Regards

Suresh