Object onDismiss(Long alertId) { // If the alert was created inside an Ajax request and AlertStorage did not previously // exist, it can be null when the dismiss event comes up from the client. if (storage != null) { if (alertId != null) { storage.dismiss(alertId); } else { storage.dismissAll(); } } return null; }
boolean beginRender(MarkupWriter writer) { clientId = javaScriptSupport.allocateClientId(resources); if (storage != null) { List<Alert> alerts = storage.getAlerts(); if (!alerts.isEmpty()) { for (Alert alert : alerts) { String alertType = alert.severity.name().toLowerCase(); String css = alertType; if ("info".equals(alertType)) { css = "success"; } css = "alert-" + css; writer.element("div", "id", clientId, "class", "alert " + css); { resources.renderInformalParameters(writer); String dismiss = resources.createEventLink("dismiss", alert.id).toURI(); if (alert.duration.persistent) { writer.element("a", "href", dismiss, "class", "close"); } else { writer.element("a", "href", "#", "class", "close", "data-dismiss", "alert"); } writer.write(dismissText); writer.end(); writer.write(alert.message); } writer.end(); } } storage.dismissNonPersistent(); } return false; }