return "RichFaces.ui.Message";
}
protected void encodeScript(FacesContext facesContext, UIComponent component) throws IOException {
JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
JSFunction messageObject = new JSObject(getJSClassName(), component.getClientId(facesContext));
Map<String, Object> attributes = component.getAttributes();
Builder<String, Object> parametersBuilder = ImmutableMap.builder();
String forId = (String) attributes.get("for");
RendererUtils rendererUtils = RendererUtils.getInstance();
if (!Strings.isNullOrEmpty(forId)) {
UIComponent target = rendererUtils.findComponentFor(component, forId);
if (null != target) {
parametersBuilder.put("forComponentId", target.getClientId(facesContext));
}
}
Severity level = getLevel(component);
if (FacesMessage.SEVERITY_INFO != level) {
parametersBuilder.put("level", level.getOrdinal());
}
if (!rendererUtils.isBooleanAttribute(component, "showSummary")) {
parametersBuilder.put("showSummary", false);
}
if (rendererUtils.isBooleanAttribute(component, "showDetail")) {
parametersBuilder.put("showDetail", true);
}
if (rendererUtils.isBooleanAttribute(component, "tooltip")) {
parametersBuilder.put("tooltip", true);
}
if (isComponentMessages(component) && rendererUtils.isBooleanAttribute(component, "globalOnly")) {
parametersBuilder.put("globalOnly", true);
}
if (isComponentMessages(component)) {
parametersBuilder.put("isMessages", true);
}
messageObject.addParameter(parametersBuilder.build());
// RendererUtils.getInstance().writeScript(facesContext, component, messageObject);
javaScriptService.addPageReadyScript(facesContext, messageObject);
}