protected void encodeMarkup(FacesContext context, ConfirmationDialog dialog) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = dialog.getClientId(context); String messageText = dialog.getMessage(); UIComponent messageFacet = dialog.getFacet("message"); writer.startElement("div", null); writer.writeAttribute("id", clientId, null); writer.startElement("div", null); String header = dialog.getHeader(); if (header != null) { writer.writeAttribute("title", header, null); } // body writer.startElement("p", null); // severity writer.startElement("span", null); writer.writeAttribute("style", "float: left; margin: 0pt 7px 20px 0pt;", null); writer.writeAttribute("class", "ui-icon ui-icon-" + dialog.getSeverity(), null); writer.endElement("span"); if (messageFacet != null) { messageFacet.encodeAll(context); } else if (messageText != null) { writer.write(messageText); } writer.endElement("p"); // buttons writer.startElement("div", null); writer.writeAttribute("id", clientId + "_buttons", null); renderChildren(context, dialog); writer.endElement("div"); writer.endElement("div"); encodeScript(context, dialog); writer.endElement("div"); }
protected void encodeScript(FacesContext context, ConfirmationDialog dialog) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = dialog.getClientId(); boolean ariaEnabled = EnvUtils.isAriaEnabled(context); writer.startElement("script", dialog); writer.writeAttribute("type", "text/javascript", null); JSONBuilder jb = JSONBuilder.create(); jb.initialiseVar(this.resolveWidgetVar(dialog)) .beginFunction("ice.ace.create") .item("ConfirmDialog") .beginArray() .item(clientId) .beginMap() .entry("minHeight", 0); String styleClass = dialog.getStyleClass(); String style = dialog.getStyle(); String showEffect = dialog.getShowEffect(); String hideEffect = dialog.getHideEffect(); int width = dialog.getWidth(); int height = dialog.getHeight(); int zIndex = dialog.getZindex(); String handle = dialog.getDragHandle(); if (styleClass != null) jb.entry("dialogClass", styleClass); if (style != null) jb.entry("dialogStyle", style); if (width != 300) jb.entry("width", width); if (height != Integer.MIN_VALUE) jb.entry("height", height); if (!dialog.isDraggable()) jb.entry("draggable", false); if (dialog.isModal()) jb.entry("modal", true); if (zIndex != 1000) jb.entry("zIndex", zIndex); if (showEffect != null) jb.entry("show", showEffect); if (hideEffect != null) jb.entry("hide", hideEffect); if (!dialog.isCloseOnEscape()) jb.entry("closeOnEscape", false); if (!dialog.isClosable()) jb.entry("closable", false); if (handle != null) jb.entry("handle", handle); // Position String position = dialog.getPosition(); if (position != null) { if (position.contains(",")) jb.entry("position", "[" + position + "]", true); else jb.entry("position", position); } jb.entry("ariaEnabled", ariaEnabled); jb.endMap().endArray().endFunction(); writer.write(jb.toString()); writer.endElement("script"); }