cancel
Showing results for 
Search instead for 
Did you mean: 

Get Discription part of dropdownbykey

Former Member
0 Kudos

Hi,

I have a dropdownbykey in my application. And selected key property of that is mapped to a context. And that context is mapped to one simple type. When u select the drop down and try fetch the drop down you will get the value part of the simple type.

i e

String str2=wdContext.currentCreateCityElement().getCountry();

But how to get the description portion of the simple type. The value which is visible to us when u click on that dropdown.

Regards,

H.V.Swathi

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Swathi,

You can use following code:



 public java.lang.String getTextFromSimpleType( com.sap.dictionary.runtime.IDataType dataType, java.lang.Object index )  {
    //@@begin getTextFromSimpleType()
	  String text = null;
	  String attrName = dataType.getLocalName();
	  
	  if(wdContext.getNodeInfo().getAttribute(attrName)==null){
		  wdContext.getNodeInfo().addAttribute(attrName,dataType);
	  }
	  text = wdContext.getNodeInfo().getAttribute(attrName).getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet().getText(index);

	  return text;
    //@@end
  }

You can get the datatype from :


IDataType dataType = wdContext.nodeCreateCity().getNodeInfo().getAttribute("Country").getDataType();

//and

String index = String str2=wdContext.currentCreateCityElement().getCountry();

Here the returned text will be the description which you want.

I hope this helps you!

NOTE: This is a very generic function which you can use anywhere. Even in some other DC and can use that DC as used DC. It takes care of any kind of Value set runtime itself. And it does not require any hardcoding.

Thanks and Regards,

Pravesh

Edited by: Pravesh Verma on Mar 16, 2009 7:35 AM

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Swathi

Suppose you have one node named dropdown and attribute named as dropdownValue

IModifiableSimpleValueSet ValueSet =wdContext.nodeDropdown().getNodeInfo().getAttribute("dropdownValue").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < ValueSet.size(); i++) {

Object key = ValueSet.getKey(i);

String desc = ValueSet.getText(i);

//This 2 lines for the printing of the Key and Desc of dropdown

wdContext.wdGetAPI().getController().getComponent().getMessageManager().reportSuccess("keyName"+key);

wdContext.wdGetAPI().getController().getComponent().getMessageManager().reportSuccess("Desc"+desc);

}

Hope this solution should work.

Former Member
0 Kudos

Hi,

IModifiableSimpleValueSet PasswordValueSet =

wdContext

.getNodeInfo()

.getAttribute("<attribute name>")

.getModifiableSimpleType()

.getSVServices()

.getModifiableSimpleValueSet();

Object keyName = PasswordValueSet.getKey(); //value

String keyStrName = keyName.toString();

String textName = PasswordValueSet.getText();//text

Please use this code to get the description part of the ST. Please loop it to get all the text values.

for (idxn = 0; idxn < PasswordValueSet.Size; idxn++) {

Object keyName = PasswordValueSet.getKey(); //value

String keyStrName = keyName.toString(idxn);

String textName = PasswordValueSet.getText(idxn);//text

}

Jithin

Edited by: jithin james on Mar 16, 2009 12:30 PM

Edited by: jithin james on Mar 16, 2009 12:42 PM

Edited by: jithin james on Mar 16, 2009 12:42 PM