@Override protected void onConfigure() { super.onConfigure(); // set all components visible Components.show(help, label, feedback); // clear feedback message and current state stateClassName.setObject(""); feedback.setDefaultModelObject(""); final List<FormComponent<?>> formComponents = findFormComponents(); for (final FormComponent<?> fc : formComponents) { final FeedbackMessages messages = fc.getFeedbackMessages(); if (!messages.isEmpty()) { final FeedbackMessage worstMessage = getWorstMessage(messages); worstMessage.markRendered(); stateClassName.setObject(toClassName(worstMessage)); feedback.setDefaultModelObject(worstMessage.getMessage()); break; // render worst message of first found child component with feedback message } } Components.hideIfModelIsEmpty(help); Components.hideIfModelIsEmpty(label); Components.hideIfModelIsEmpty(feedback); }
/** * returns the worst message that is available. * * @param messages all current feedback messages * @return worst possible message or null */ private FeedbackMessage getWorstMessage(final FeedbackMessages messages) { for (final Integer messageType : messageTypes) { final FeedbackMessage ret = messages.first(messageType); if (ret != null) { return ret; } } return messages.first(); }
/** On affiche le premier message correspondant au composant. */ @Override public void afterRender(Component component) { FormComponent<?> f = (FormComponent<?>) component; Response response = component.getResponse(); FeedbackMessages messages = f.getSession().getFeedbackMessages(); if (messages.hasMessageFor(component)) { IFeedbackMessageFilter filter = new ComponentFeedbackMessageFilter(component); response.write( "<span class=\"help-inline\">" + messages.messages(filter).get(0).getMessage() + "</span>"); } }