Search in sources :

Example 1 with DialogOpenTrigger

use of com.github.bordertech.wcomponents.DialogOpenTrigger in project wcomponents by BorderTech.

the class WDialogRenderer method doRender.

/**
 * Paints the given WDialog.
 *
 * @param component the WDialog to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WDialog dialog = (WDialog) component;
    int state = dialog.getState();
    if (state == WDialog.ACTIVE_STATE || dialog.getTrigger() != null) {
        int width = dialog.getWidth();
        int height = dialog.getHeight();
        String title = dialog.getTitle();
        XmlStringBuilder xml = renderContext.getWriter();
        xml.appendTagOpen("ui:dialog");
        xml.appendAttribute("id", component.getId());
        xml.appendOptionalAttribute("class", component.getHtmlClass());
        xml.appendOptionalAttribute("track", component.isTracking(), "true");
        xml.appendOptionalAttribute("width", width > 0, width);
        xml.appendOptionalAttribute("height", height > 0, height);
        xml.appendOptionalAttribute("modal", dialog.getMode() == WDialog.MODAL, "true");
        xml.appendOptionalAttribute("open", dialog.getState() == WDialog.ACTIVE_STATE, "true");
        xml.appendOptionalAttribute("title", title);
        DialogOpenTrigger trigger = dialog.getTrigger();
        if (trigger != null) {
            xml.appendOptionalAttribute("triggerid", trigger.getId());
            if (dialog.hasLegacyTriggerButton()) {
                xml.appendClose();
                trigger.paint(renderContext);
                xml.appendEndTag("ui:dialog");
            } else {
                xml.appendEnd();
            }
        } else {
            xml.appendEnd();
        }
    }
}
Also used : WDialog(com.github.bordertech.wcomponents.WDialog) DialogOpenTrigger(com.github.bordertech.wcomponents.DialogOpenTrigger) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

DialogOpenTrigger (com.github.bordertech.wcomponents.DialogOpenTrigger)1 WDialog (com.github.bordertech.wcomponents.WDialog)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1