18.3.2.  Example 2: dynamic values (dropdown menu with predefined values)

If the data to enter is a choice instead of a free-text value, you can also define those in the descriptor like shown here:
<identity-ui-configuration>
...
    <!-- user interface components -->
        ...
        <ui-component name="interests">
            <property-ref>portal.user.interests</property-ref>
            <values>
                <value key="board">snowboarding</value>
                <value key="ski">skiing</value>
                <value key="sledge">sledging</value>
            </values>
        </ui-component>
        ...
</identity-ui-configuration>
In portal-identity.sar/portal-identity.war/WEB-INF/jsf/common/profile.xhtml - change inputText to a selectOneMenu:
    ...
    <h:outputText value="#{bundle.IDENTITY_INTERESTS}"/>
    <h:selectOneMenu id="interests" value="#{manager.uiUser.attribute.interests}"
        required="#{metadataservice.interests.required}">
    <f:selectItems value="#{metadataservice.interests.values}" />
    </h.selectOneMenu>
    <h:panelGroup />
    <h:message for="interests"/>
...
For localizing dynamic values it is also possible to use the resource bundle. This can be done by adding the key with a prefix (to i.e. Identity.properties) like in the following listing. The key will be stored in the users property and is used to identify the element. The value of the configuration file will only be used if no localization information is found.
...
IDENTITY_DYNAMIC_VALUE_BOARD=localized snowboarding
IDENTITY_DYNAMIC_VALUE_SKI=localized skiing
IDENTITY_DYNAMIC_VALUE_SLEDGE=localized sledging
...

Note

If the value is not required a blank element will be added at the top.