Class opensocial.Enum
Base interface for all enum objects. This class allows containers to use constants for fields that are usually have a common set of values. There are two main ways to use this class.
If your gadget just wants to display how much of a smoker someone is, it can simply use:
html = "This person smokes: " + person.getField('smoker').getValue();
This value field will be correctly set up by the container. This is a place where the container can even localize the value for the gadget so that it always shows the right thing.
If your gadget wants to have some logic around the smoker field it can use:
if (person.getField('smoker').getKey() != "NO") { //gadget logic here }
Note: The key may be null if the person's smoker field cannot be coerced into one of the standard enum types. The value, on the other hand, is never null.
Defined in: opensocial.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Method Attributes | Method Name and Description |
|---|---|
|
The value of this enum.
|
|
|
getKey()
Use this for logic within your gadget.
|
Method Detail
{String}
getDisplayValue()
The value of this enum. This will be a user displayable string. If the
container supports localization, the string will be localized.
- Returns:
- {String} The enum's value.
{String}
getKey()
Use this for logic within your gadget. If they key is null then the value
does not fit in the defined enums.
- Returns:
- {String} The enum's key. This should be one of the defined enums below.