Example usage for org.apache.wicket.feedback FeedbackMessages first

List of usage examples for org.apache.wicket.feedback FeedbackMessages first

Introduction

In this page you can find the example usage for org.apache.wicket.feedback FeedbackMessages first.

Prototype

public final FeedbackMessage first(final int level) 

Source Link

Document

Retrieves the first message that level is greater than or equal to the given level

Usage

From source file:org.lbogdanov.poker.web.markup.ControlGroup.java

License:Apache License

/**
 * @see Border#Border(String, IModel)//from w w  w  .  j  a va  2 s. c o m
 */
public ControlGroup(String id, IModel<String> model) {
    super(id, model);
    addToBorder(label = new Label("label", getDefaultModel()));
    add(AttributeModifier.append("class", "control-group"));
    add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            FormComponent<?> formComponent = lastFormComponent();
            if (formComponent != null) {
                FeedbackMessages messages = formComponent.getFeedbackMessages();
                if (!messages.isEmpty()) {
                    for (int type : MESSAGE_TYPES) {
                        FeedbackMessage message = messages.first(type);
                        if (message != null) {
                            return messageToCssClass(message);
                        }
                    }
                    return messageToCssClass(messages.first());
                }
            }
            return null;
        }

    }));
}