on 03-16-2009 11:04 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.