@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); }
private void writeMessages(Component component, Response response) { // // Note how bootstrap cannot have separate markup // for error/info messages attached to the same field. // for (FeedbackMessage message : collectMessages(component)) { response.write("<span class=\"help-block\">"); response.write(Strings.escapeMarkup(message.getMessage().toString())); response.write("</span>"); } }
/** {@inheritDoc} */ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (!isValid()) { tag.put("class", "imxt-invalid"); FeedbackMessage message = getFeedbackMessages().first(); if (message != null) { tag.put("title", message.getMessage().toString()); } } }
@Override protected void populateItem(ListItem<FeedbackMessage> item) { FeedbackMessage message = item.getModelObject(); message.markRendered(); Panel panel = null; if (isTempPanel) { panel = new TempMessagePanel("message", item.getModel()); } else { panel = new FeedbackMessagePanel("message", item.getModel()); } panel.add(new AttributeAppender("class", createModel(item.getModel()), " ")); item.add(panel); }
@Override public String apply(final FeedbackMessage message) { if (message == null) { return ""; } switch (message.getLevel()) { case FeedbackMessage.FATAL: case FeedbackMessage.ERROR: return "has-error"; case FeedbackMessage.WARNING: return "has-warning"; case FeedbackMessage.INFO: case FeedbackMessage.SUCCESS: return "has-success"; default: return ""; } }