cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get enumeration description from simple type?

Former Member
0 Kudos

Hello!

I want to display the value of a simple type in a table and display the description in a tool tip for the cell, how do I do that?

I'm using Web dynpro for java 7.0 ehp1.

I'm using an enumeration with 5 possible values with corresponding descriptions.

If I use a (read only) dropdownByKey the description is shown in the drop down, but I only want to show it as a tooltip since it takes up some screen space.

I would like to use a textview, is there a simple way to get the description as a tooltip? I thought about doing a calculated attribute that gets the description but I'm not sure about how to do it or if its the easiest way.

Thank you for any help!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Richard,

for getting the description of the simple type attribute ( Ex.X) create a context attribute of type string (Ex. Y) and bind it to the tooltip property of table cell editor.

Set the read only and calculated property of the attribute Y to true.

Put this code in the automatic generated method for calculated attribute :-

String value1 = nodeElement.getX;

IWDAttributeInfo attInfo = wdContext.getNodeInfo().getAttribute("X");

ISimpleValueSet valueset = attInfo.getModifiableSimpleType().getSVServices().getValues();

if(valueset.containsKey(value1)){

String value2 = valueset.getText(value1);

wdContext.node<NodeName>.setY(value2);

}

By this way you can set the description of the simple type as tooltip but by using dropdown by key and index you cannot show the valueof the simple type in the UI.

So another way is bind the simple type attribute to a inputfield uielement in the table column. Your simple type enumeration data will come as a F4 help in the UI and after selection you will be able to see value in inputt field and description as a tooltip.

Regards

Ravindra

Former Member
0 Kudos

Thank you both!

My problem is solved.

There is a nice explanation in this article as well, written by Bertram Ganz

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/391ee590-0201-0010-1c89-f1193a886421

Since my element used structure binding I had to add the calculated attribute as a child node so this is the end result:

String attributeName = IPrivateTotalLonView.IEt_TotalsummorElement.LONBAS;

IWDAttributeInfo attributeInfo =

element.node().getParentElement().node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

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

Object key = element.node().getParentElement().getAttributeValue(attributeName);

try {

simpleType.checkValid(key);

return valueset.getText(key);

} catch (DdCheckException e) {

return "";

}

Answers (1)

Answers (1)

former_member214651
Active Contributor
0 Kudos

Hi,

Use the ISimpleTypeModifiable() to get the Description of the key. And moreover, since the simpleType enumeration contains data at design time itself and are static values, the description can be set in the code based on the Key:

eg:

if the enum values are

0-->One

1-->Two

2-->Three etc...

on Action of the DD u can directly set the value like

if(("0").equalsIgnoreCase(wdContext.currentContextElement().getKey())

{

-->wdContext().currentContextElement().setDescription("One");

}

Hope this helps u.

Reference: -

Regards,

Poojith MV