Avatars
In ADITO, so-called Avatars are small visual components that are auto-generated by the ADITO platform's logic for all EntityFields of contentType IMAGE.
Example:
In PersonFilter_view, column PICTURE shows icon-typed images of the persons. However, if EntityField PICTURE of a Person dataset does not hold an image, the first letters of first name and last name are displayed on a square, colored background. (The configuration of this behavior is done in PICTURE's displayValueProcess, see below.)
![]()
For a better understanding of the following, you need to know that the ADITO platform automatically converts binary images (after being loaded from the database) into base64 strings, before perfoming subsequent logic. Thus, the value of an EntityField of contentType IMAGE is always a string, not a binary object.
The ADITO platform's Avatar auto-generation logic for EntityFields of contentType IMAGE works as follows:
- If the EntityField is to be displayed in a ViewTemplate of type "Picture", the value is interpreted as base64 image, which is then shown without additions (no background etc.). The following steps are skipped.
- The logic checks if the value includes character ":" (colon). If not, the value is interpreted as base64 image, which is then shown it without additions (no background etc.). The following steps are skipped.
- The subsequent steps of the logic depend on the prefix (= the string part preceeding the ":" character):
- prefix "TEXT": 0-2 characters are shown on a colored, square background, according to the following logic:
- First, the part of the string that follows the ":" character is split into substrings, using " " (space) as delimiter.
- Empty substrings are sorted out. The remaining substrings are the actual basis for generating Avatar character(s):
- If there is only one substring, its first 2 characters are used. If the substring contains only 1 character, the Avatar will show only this single character.
- If there are multiple substrings, the first characters of the first 2 substrings are used. There is one exception: If the first character of a substring is a non-letter character, then this substring is skipped, and instead the first letter of the next substring is used. This logic is helpful when, e.g., a company name like "Energystar - Oil Company" is given; in this example, the letters "EO" would be extracted, not "E-".
- Example from the xRM project's Context "Person": If there is no image of the person available, the displayValue of EntityField PICTURE starts with "TEXT:", followed by the values of first name, last name, and company name (separated by a "space"). Thus, the auto-generated Avatar characters are usually the first letter of the first name and the first letter of the last name. If, however, a first name is not available (= this substring is empty), then the Avatar's characters will be the first letter of the last name and the first letter of the company name.
- The color of the Avatar's square background depends on the color-related properties of the respective EntityField (
colororcolorProcess). If none of these properties is set, the background color is generated on the basis of a hash value of the original string.
Note: The auto-generation logic is, of course, limited to the colors defined in the "Theme" (see chapters Themes and Color). Thus, the logic cannot ensure that a unique color is assigned to each single dataset.
- prefix "NEON" or prefix "VAADIN": The complete string is interpreted as name of one of the official icons provided by the ADITO platform. You can browse the names of the available icons, e.g., via scanning the combobox of an "icon" property (see chapter Icons for further information).
- prefix "URL": The part of the string that follows the ":" character is interpreted as an URL, pointing to an external image.
- prefix "TEXT": 0-2 characters are shown on a colored, square background, according to the following logic:
Example task: Given be an EntityField MYIMAGEFIELD, which has the contentType IMAGE. Now, if no image can be loaded from the database, the value of MYIMAGEFIELD should be a combination of the first characters of text-typed EntityFields ENTITIYFIELD1 and ENTITIYFIELD2. If ENTITIYFIELD2 is empty or starts with a non-letter character, the first character of ENTITIYFIELD3 should be used instead.
To achieve this, you need to program a logic for setting a textual value for covering the case that a real image is not available. Usually, this is done in MYIMAGEFIELD's valueProcess or displayValueProcess, including a case like this:
if (vars.get("$field.MYIMAGEFIELD"))
result.string(vars.get("$field.MYIMAGEFIELD"));
else
result.string("TEXT:"
+ vars.getString("$field.ENTITIYFIELD1") + " "
+ vars.getString("$field.ENTITIYFIELD2") + " "
+ vars.getString("$field.ENTITIYFIELD2"));
The ADITO platform's logic will then auto-generate an Avatar on the basis of the string as concatenated in the "else" part of the above code fragment.
Further examples:
For testing purposes, you may
- create an EntityField (e.g.,
name="PICTURE",title="Avatar Test",contentType=IMAGE) for a suitable Entity of the xRM Project - e.g., Interest_entity (module communicationsettings), - assign it to a suitable View (e.g., to InterestFilter_view), and
- enter the following
valueProcess:
// Avatar with characters "XA" on colored background
result.string("TEXT:xyz ABC mno");
// Icon showing "plus" symbol
result.string("NEON:PLUS");
// Icon showing "factory" symbol
result.string("VAADIN:FACTORY");
// URL pointing to image of shopping cart
result.string("URL:https://www.adito.de/fileadmin/uploads/icons/menueicons/adito_icon_handel.svg");
// ADITO logo as base64
result.string("iVBORw0KGgoAAAANSUhEUgAAAFIAAABJCAYAAACuPXHDAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUA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fQnkI1UbQblKOdUZ7Z30nEkC1wO1qA0oj+Lownj2GcOYKwImhdQqtyc0UHr2ojgXclHmzPK9kIx7b15fUMa6Vw3XrrnSd6Ypzq7SRmynBjVisxJJQc/Mkl1GoKXQ7pJ1NJy97fg3FyEDm4j/8DfVzmYRdMaRwAAAAASUVORK5CYII=");
If the Avatar logic fails for whatever reason (e.g., the prefix or the base64 is not valid) a circled "exclamation mark" icon is shown instead of the Avatar (or, in some cases, no Avatar at all).