cancel
Showing results for 
Search instead for 
Did you mean: 

Related to calculated property

Former Member
0 Kudos

Hi All,

Why we use calculated property for a context attribute as true? Give me an example.

Regards

DK

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

Hi DK,

Calculated Property is required when you want to handle node context attribute programmatically.

When you say Context Attribute as True, it generates two methods, Setter and Getter Method for that attribute.

In getter method you will be getting one ‘element’ it is the context node, where you created attribute. These methods will be called automatically.

If you want to pass calculated value to the table and then use the context attribute property as calculated. In the getter method you do the calculations.

For more information refer this link.

http://help.sap.com/saphelp_nw2004s/helpdata/en/7f/a0384162316532e10000000a1550b0/frameset.htm

Example :

In the below example, converting the result node integer value to string.

Regards,

Sridhar

Answers (1)

Answers (1)

Former Member
0 Kudos

Calculated attributes are a handy way for combining or transforming attributes of the same node.

Example: You have an attribute "Value" storing some numeric value and you want to give a TextView a certain color, if the value is negative.

Then you can create a calculated (read-only) attribute "TextColor" of type "TextViewSemanticColor" and bind the "semanticColor" property of a TextView to this attribute.

In the generated getTextColor() method, you simply write

WDTextViewSemanticColor getTextColor(I<Node>Element element)
{
  return element.getValue() < 0
    ? WDTextViewSemanticColor.NEGATIVE
    : WDTextViewSemanticColor.STANDARD;
}

Same technique may be used to set other UI element state (enabled, read-only) depending on existing attribute values.

More applications: Formatting of "display" values.

Armin