List of usage examples for org.apache.wicket Component hasFeedbackMessage
public final boolean hasFeedbackMessage()
From source file:ca.travelagency.components.decorators.FieldDecorator.java
License:Apache License
@Override public void afterRender(Component component) { Response response = component.getResponse(); if (component.hasFeedbackMessage()) { response.write("<ul class=\"feedbackPanel\">"); FeedbackMessages feedbackMessages = component.getFeedbackMessages(); for (FeedbackMessage message : feedbackMessages) { response.write("<li class=\"feedbackPanel"); response.write(message.getLevelAsString().toUpperCase()); response.write("\">"); response.write(Strings.escapeMarkup(message.getMessage().toString())); response.write("</li>"); message.markRendered();//from w ww . j a v a 2s . c o m } response.write("</ul>"); } response.write("</span>"); super.afterRender(component); }
From source file:guru.mmp.application.web.template.util.FeedbackUtil.java
License:Apache License
/** * Generate the Javascript to display the feedback for the specified component. * * @param id the id of the component to provide the feedback for * @param component the component to generate the feedback JavaScript for * @param isAjaxRequest is feedback being generated as part of an Ajax request * @param feedbackMessageClasses the additional CSS classes to apply to the feedback message * * @return the JavaScript to display the feedback message or <code>null</code> * if there is no feedback for the specified component *///from w w w. j a va 2 s. com public static String generateFeedbackJavaScript(String id, Component component, boolean isAjaxRequest, String feedbackMessageClasses) { if (component.hasFeedbackMessage()) { FeedbackMessages feedbackMessages = component.getFeedbackMessages(); FeedbackMessage feedbackMessage = feedbackMessages.first(); String feedbackClass = null; if (feedbackMessage.isError()) { feedbackClass = "has-error"; } else if (feedbackMessage.isFatal()) { feedbackClass = "has-error"; } else if (feedbackMessage.isWarning()) { feedbackClass = "has-warning"; } else if (feedbackMessage.isInfo()) { feedbackClass = "has-info"; } else if (feedbackMessage.isDebug()) { feedbackClass = "has-success"; } String javaScript = String.format( isAjaxRequest ? SHOW_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT : DOM_READY_SHOW_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT, id, feedbackClass, StringUtil.notNull(feedbackMessageClasses), JavaScriptUtils.escapeQuotes(feedbackMessage.getMessage().toString())); // Clear the feedback messages for the component for (FeedbackMessage componentFeedbackMessage : feedbackMessages) { componentFeedbackMessage.markRendered(); } return javaScript; } else { if (isAjaxRequest) { return String.format(CLEAR_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT, id); } return null; } }