Search in sources :

Example 1 with MessagesPerFieldBean

use of org.keycloak.theme.beans.MessagesPerFieldBean in project keycloak by keycloak.

the class FreeMarkerLoginFormsProvider method handleMessages.

/**
 * Handle messages to be shown on the page - set them to template attributes
 *
 * @param locale to be used for message text loading
 * @param messagesBundle to be used for message text loading
 * @see #messageType
 * @see #messages
 */
protected void handleMessages(Locale locale, Properties messagesBundle) {
    MessagesPerFieldBean messagesPerField = new MessagesPerFieldBean();
    if (messages != null) {
        MessageBean wholeMessage = new MessageBean(null, messageType);
        for (FormMessage message : this.messages) {
            String formattedMessageText = formatMessage(message, messagesBundle, locale);
            if (formattedMessageText != null) {
                wholeMessage.appendSummaryLine(formattedMessageText);
                messagesPerField.addMessage(message.getField(), formattedMessageText, messageType);
            }
        }
        attributes.put("message", wholeMessage);
    } else {
        attributes.put("message", null);
    }
    attributes.put("messagesPerField", messagesPerField);
}
Also used : MessageBean(org.keycloak.theme.beans.MessageBean) MessagesPerFieldBean(org.keycloak.theme.beans.MessagesPerFieldBean) FormMessage(org.keycloak.models.utils.FormMessage)

Example 2 with MessagesPerFieldBean

use of org.keycloak.theme.beans.MessagesPerFieldBean in project keycloak by keycloak.

the class FreeMarkerAccountProvider method handleMessages.

/**
 * Handle messages to be shown on the page - set them to template attributes
 *
 * @param locale to be used for message text loading
 * @param messagesBundle to be used for message text loading
 * @param attributes template attributes to messages related info to
 * @see #messageType
 * @see #messages
 */
protected void handleMessages(Locale locale, Properties messagesBundle, Map<String, Object> attributes) {
    MessagesPerFieldBean messagesPerField = new MessagesPerFieldBean();
    if (messages != null) {
        MessageBean wholeMessage = new MessageBean(null, messageType);
        for (FormMessage message : this.messages) {
            String formattedMessageText = formatMessage(message, messagesBundle, locale);
            if (formattedMessageText != null) {
                wholeMessage.appendSummaryLine(formattedMessageText);
                messagesPerField.addMessage(message.getField(), formattedMessageText, messageType);
            }
        }
        attributes.put("message", wholeMessage);
    }
    attributes.put("messagesPerField", messagesPerField);
}
Also used : MessageBean(org.keycloak.theme.beans.MessageBean) MessagesPerFieldBean(org.keycloak.theme.beans.MessagesPerFieldBean) FormMessage(org.keycloak.models.utils.FormMessage)

Aggregations

FormMessage (org.keycloak.models.utils.FormMessage)2 MessageBean (org.keycloak.theme.beans.MessageBean)2 MessagesPerFieldBean (org.keycloak.theme.beans.MessagesPerFieldBean)2