Example usage for javax.servlet.jsp.tagext JspFragment invoke

List of usage examples for javax.servlet.jsp.tagext JspFragment invoke

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext JspFragment invoke.

Prototype

public abstract void invoke(Writer out) throws JspException, IOException;

Source Link

Document

Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null.

Usage

From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java

public static String getBody(JspFragment fragment) throws JspException, IOException {
    if (fragment == null)
        return "";
    StringWriter body = new StringWriter();
    fragment.invoke(body);
    body.close();//from  w w  w  .jav a 2  s. c o  m
    return body.toString().trim();
}

From source file:com.jsmartframework.web.tag.TooltipTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    StringWriter sw = new StringWriter();
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(sw);
    }//from  w  ww  .  j  a va2s. c om

    // Place the tag content as template
    template = sw.toString();

    if (StringUtils.isNotBlank(template)) {
        setRandomId("tooltip");

        // The HTML template must overwrite the title
        title = null;
    }
    return null;
}

From source file:com.jsmartframework.web.tag.PopOverTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    StringWriter sw = new StringWriter();
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(sw);
    }/*from  w w  w . j  a v  a2 s.c om*/

    // Place the tag content as template
    template = sw.toString();

    if (StringUtils.isNotBlank(template)) {
        setRandomId("popover");

        // The HTML template must overwrite the content
        content = null;
    }
    return null;
}

From source file:com.jsmartframework.web.tag.FunctionTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(null);
    }/*from  ww  w  .  j av a2  s  .c  om*/

    Ajax jsonAjax = getJsonAjax(WebContext.getRequest(), id);
    StringBuilder scriptBuilder = new StringBuilder(JSMART_AJAX.format(getJsonValue(jsonAjax)));
    appendFunction(getFunction(id, name, functionArgs, functionVars, scriptBuilder));
    return null;
}

From source file:com.jsmartframework.web.tag.DropDownTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(null);
    }/*  w  w w . j a  v a  2s.com*/

    setRandomId("dropdown");

    Tag dropDown;
    if (navbar) {
        dropDown = new Li();
    } else {
        dropDown = new Div();
    }

    boolean disabled = isDisabled();

    dropDown.addAttribute("style", getTagValue(style)).addAttribute("class", Bootstrap.DROPDOWN)
            .addAttribute("class", disabled ? Bootstrap.DISABLED : null)
            .addAttribute("class", getTagValue(styleClass));

    appendRefId(dropDown, id);
    appendEvent(dropDown);

    A a = new A();

    for (IconTagHandler iconTag : iconTags) {
        if (Align.LEFT.equalsIgnoreCase(iconTag.getSide())) {
            a.addTag(iconTag.executeTag());
            a.addText(" ");
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.LEFT.equalsIgnoreCase(imageTag.getSide())) {
            a.addTag(imageTag.executeTag());
            a.addText(" ");
        }
    }

    String labelVal = (String) getTagValue(label);

    a.addAttribute("href", "#").addAttribute("data-toggle", "dropdown").addAttribute("aria-expanded", "false")
            .addAttribute("class", Bootstrap.DROPDOWN_TOGGLE)
            .addText(StringUtils.isNotBlank(labelVal) ? labelVal
                    : StringUtils.isBlank(caretClass) ? "‌" : null);

    for (IconTagHandler iconTag : iconTags) {
        if (Align.RIGHT.equalsIgnoreCase(iconTag.getSide())) {
            a.addText(" ");
            a.addTag(iconTag.executeTag());
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.RIGHT.equalsIgnoreCase(imageTag.getSide())) {
            a.addText(" ");
            a.addTag(imageTag.executeTag());
        }
    }

    if (dropMenu != null) {
        Span span = new Span();
        String caretName = (String) getTagValue(caretClass);
        if (StringUtils.isNotBlank(caretName)) {
            if (caretName.startsWith(Bootstrap.GLYPHICON)) {
                span.addAttribute("class", Bootstrap.GLYPHICON);
            }
            span.addAttribute("class", caretName);
        } else {
            span.addAttribute("class", Bootstrap.CARET);
        }
        a.addText(" ");
        a.addTag(span);
    }

    dropDown.addTag(a);

    if (dropMenu != null) {
        Tag ul = dropMenu.executeTag();
        ul.addAttribute("class", disabled ? Bootstrap.DISABLED : null);
        dropDown.addTag(ul);
    }

    appendAjax(id);
    appendBind(id);

    return dropDown;
}

From source file:com.jsmartframework.web.tag.DropActionTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    StringWriter sw = new StringWriter();

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(sw);
    }//from  w  w w  .ja v  a2s.  c  om

    Set set = new Set();
    setRandomId("dropaction");

    if (header != null) {
        Li headerLi = new Li();
        headerLi.addAttribute("role", "presentation").addAttribute("class", Bootstrap.DROPDOWN_HEADER)
                .addText(getTagValue(header));
        set.addTag(headerLi);
    }

    Li li = new Li();
    li.addAttribute("id", id).addAttribute("role", "presentation").addAttribute("style", getTagValue(style))
            .addAttribute("class", disabled ? Bootstrap.DISABLED : null)
            .addAttribute("class", getTagValue(styleClass));
    set.addTag(li);

    appendEvent(li);

    A a = new A();
    a.addAttribute("style", "cursor: pointer;");
    li.addTag(a);

    for (IconTagHandler iconTag : iconTags) {
        if (Align.LEFT.equalsIgnoreCase(iconTag.getSide())) {
            a.addTag(iconTag.executeTag());
            a.addText(" ");
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.LEFT.equalsIgnoreCase(imageTag.getSide())) {
            a.addTag(imageTag.executeTag());
            a.addText(" ");
        }
    }

    a.addText(sw.toString());
    a.addText(getTagValue(label));

    for (IconTagHandler iconTag : iconTags) {
        if (Align.RIGHT.equalsIgnoreCase(iconTag.getSide())) {
            a.addText(" ");
            a.addTag(iconTag.executeTag());
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.RIGHT.equalsIgnoreCase(imageTag.getSide())) {
            a.addText(" ");
            a.addTag(imageTag.executeTag());
        }
    }

    if (divider) {
        Li dividerLi = new Li();
        dividerLi.addAttribute("class", Bootstrap.DIVIDER);
        set.addTag(dividerLi);
    }

    StringBuilder urlParams = new StringBuilder("?");
    for (String key : params.keySet()) {
        urlParams.append(key + "=" + params.get(key) + "&");
    }

    String url = "";
    String outcomeVal = WebUtils.decodePath((String) getTagValue(outcome));
    if (outcomeVal != null) {
        url = (outcomeVal.startsWith("/") ? outcomeVal.replaceFirst("/", "") : outcomeVal)
                + urlParams.substring(0, urlParams.length() - 1);
    }

    String href = "#";
    if (action == null && !url.isEmpty()) {
        href = (!url.startsWith("http") && !url.startsWith("mailto") && !url.startsWith("#")
                ? getRequest().getContextPath() + "/"
                : "") + url;
        a.addAttribute("href", href);
    } else {
        appendDocScript(getFunction());
    }
    return set;
}

From source file:com.jsmartframework.web.tag.InputTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(null);
    }//from w  w  w .ja v  a2s. c  o  m

    setRandomId("input");

    Div formGroup = null;
    Div inputGroup = null;

    JspTag parent = getParent();
    if (!Type.HIDDEN.equalsIgnoreCase(type)
            && (label != null || parent instanceof FormTagHandler || parent instanceof RestTagHandler)) {
        formGroup = new Div();
        formGroup.addAttribute("class", Bootstrap.FORM_GROUP);

        String size = null;
        if (parent instanceof FormTagHandler) {
            size = ((FormTagHandler) parent).getSize();
        } else if (parent instanceof RestTagHandler) {
            size = ((RestTagHandler) parent).getSize();
        }
        if (Size.LARGE.equalsIgnoreCase(size)) {
            formGroup.addAttribute("class", Bootstrap.FORM_GROUP_LARGE);
        } else if (Size.SMALL.equalsIgnoreCase(size)) {
            formGroup.addAttribute("class", Bootstrap.FORM_GROUP_SMALL);
        }
    }

    if (!Type.HIDDEN.equalsIgnoreCase(type) && label != null) {
        Label labelTag = new Label();
        labelTag.addAttribute("for", id).addAttribute("class", Bootstrap.LABEL_CONTROL)
                .addText(getTagValue(label));
        formGroup.addTag(labelTag);
    }

    if (!Type.HIDDEN.equalsIgnoreCase(type) && (leftAddOn != null || rightAddOn != null)) {
        inputGroup = new Div();
        inputGroup.addAttribute("class", Bootstrap.INPUT_GROUP);

        if (Size.SMALL.equalsIgnoreCase(size)) {
            inputGroup.addAttribute("class", Bootstrap.INPUT_GROUP_SMALL);
        } else if (Size.LARGE.equalsIgnoreCase(size)) {
            inputGroup.addAttribute("class", Bootstrap.INPUT_GROUP_LARGE);
        }

        if (formGroup != null) {
            formGroup.addTag(inputGroup);
        }
    }

    if (!Type.HIDDEN.equalsIgnoreCase(type) && leftAddOn != null) {
        boolean foundAddOn = false;

        for (int i = 0; i < childAddOns.size(); i++) {
            if (leftAddOn.equalsIgnoreCase(childAddOns.get(i).getId())) {
                inputGroup.addTag(childAddOns.get(i).executeTag());
                foundAddOn = true;
                break;
            }
        }
        if (!foundAddOn) {
            Div div = new Div();
            div.addAttribute("class", Bootstrap.INPUT_GROUP_ADDON).addText(getTagValue(leftAddOn));
            inputGroup.addTag(div);
        }
    }

    String name = getTagName(J_TAG, value);

    Input input = new Input();
    input.addAttribute("name",
            StringUtils.isNotBlank(name) ? name + (readOnly ? EL_PARAM_READ_ONLY : "") : null)
            .addAttribute("type", type != null ? type : Type.TEXT.name().toLowerCase())
            .addAttribute("class", Bootstrap.FORM_CONTROL).addAttribute("tabindex", tabIndex)
            .addAttribute("maxlength", length).addAttribute("readonly", readOnly ? readOnly : null)
            .addAttribute("disabled", isDisabled() ? "disabled" : null)
            .addAttribute("placeholder", getTagValue(placeholder))
            .addAttribute("datatype", type != null ? type : Type.TEXT.name().toLowerCase())
            .addAttribute("pattern", pattern).addAttribute("autofocus", autoFocus ? autoFocus : null)
            .addAttribute("data-mask", mask);

    appendRefId(input, id);

    if (Size.SMALL.equalsIgnoreCase(size)) {
        input.addAttribute("class", Bootstrap.INPUT_SMALL);
    } else if (Size.LARGE.equalsIgnoreCase(size)) {
        input.addAttribute("class", Bootstrap.INPUT_LARGE);
    }

    if (Type.NUMBER.equalsIgnoreCase(type) || Type.RANGE.equalsIgnoreCase(type)) {
        input.addAttribute("min", minValue).addAttribute("max", maxValue).addAttribute("step", stepValue);
    }

    // Add the style class at last
    if (inputGroup != null) {
        inputGroup.addAttribute("style", getTagValue(style)).addAttribute("class", getTagValue(styleClass));
    } else {
        input.addAttribute("style", getTagValue(style)).addAttribute("class", getTagValue(styleClass));
    }

    if (!Type.PASSWORD.equalsIgnoreCase(type)) {
        input.addAttribute("value", getTagValue(value));
    } else {
        setTagValue(value, null);
    }

    appendValidator(input);
    appendRest(input, name);
    appendEvent(input);

    if (inputGroup != null) {
        inputGroup.addTag(input);
    } else if (formGroup != null) {
        formGroup.addTag(input);
    }

    if (!Type.HIDDEN.equalsIgnoreCase(type) && rightAddOn != null) {
        boolean foundAddOn = false;

        for (int i = 0; i < childAddOns.size(); i++) {
            if (rightAddOn.equalsIgnoreCase(childAddOns.get(i).getId())) {
                inputGroup.addTag(childAddOns.get(i).executeTag());
                foundAddOn = true;
                break;
            }
        }
        if (!foundAddOn) {
            Div div = new Div();
            div.addAttribute("class", Bootstrap.INPUT_GROUP_ADDON).addText(getTagValue(rightAddOn));
            inputGroup.addTag(div);
        }
    }

    appendAjax(id);
    appendBind(id);

    if (formGroup != null) {
        appendTooltip(formGroup);
        appendPopOver(formGroup);

    } else if (inputGroup != null) {
        appendTooltip(inputGroup);
        appendPopOver(inputGroup);

    } else if (!Type.HIDDEN.equalsIgnoreCase(type)) {
        appendTooltip(input);
        appendPopOver(input);
    }

    return formGroup != null ? formGroup : inputGroup != null ? inputGroup : input;
}

From source file:org.lightadmin.core.view.tags.form.DomainTypeElementsTag.java

@Override
public void doTag() throws JspException, IOException {

    DomainTypeBasicConfiguration domainTypeConfiguration = configuration.forDomainType(domainType);
    Assert.notNull(domainTypeConfiguration, "<domainTypeConfiguration> not found for association");

    // TODO: Implement configurable ordering
    List allElements = domainTypeConfiguration.getRepository().findAll();
    allElements = sortByNaturalOrder(allElements, domainTypeConfiguration);

    PersistentProperty idAttribute = domainTypeConfiguration.getPersistentEntity().getIdProperty();
    EntityNameExtractor<Object> nameExtractor = domainTypeConfiguration.getEntityConfiguration()
            .getNameExtractor();/*from ww  w .  ja  va2 s. c om*/
    JspContext jspContext = getJspContext();
    JspFragment tagBody = getJspBody();
    for (Object element : allElements) {
        BeanWrapper beanWrapper = new DirectFieldAccessFallbackBeanWrapper(element);

        jspContext.setAttribute(idVar, beanWrapper.getPropertyValue(idAttribute.getName()));
        jspContext.setAttribute(stringRepresentationVar,
                exceptionAwareNameExtractor(nameExtractor, domainTypeConfiguration).apply(element));
        tagBody.invoke(null);
    }
}

From source file:com.jsmartframework.web.tag.LinkTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    StringWriter sw = new StringWriter();

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(sw);
    }/*w ww. ja v a 2  s.  co  m*/

    setRandomId("link");

    Div linkGroup = null;

    if (dropMenu != null) {
        linkGroup = new Div();
        linkGroup.addAttribute("class", Bootstrap.BUTTON_GROUP).addAttribute("role", "group");

        if (Size.XSMALL.equalsIgnoreCase(size)) {
            linkGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_XSMALL);
        } else if (Size.SMALL.equalsIgnoreCase(size)) {
            linkGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_SMALL);
        } else if (Size.LARGE.equalsIgnoreCase(size)) {
            linkGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_LARGE);
        } else if (Size.JUSTIFIED.equalsIgnoreCase(size)) {
            linkGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_JUSTIFIED);
        }

        if (dropMenu.isDropUp()) {
            linkGroup.addAttribute("class", Bootstrap.DROPUP);
        }
    }

    boolean disabled = isDisabled();

    A link = new A();
    link.addAttribute("style", getTagValue(style)).addAttribute("class", Bootstrap.BUTTON)
            .addAttribute("tabindex", tabIndex).addAttribute("target", target)
            .addAttribute("class", disabled ? Bootstrap.DISABLED : null);

    String lookVal = (String) getTagValue(look);

    if (Look.PRIMARY.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_PRIMARY);
    } else if (Look.SUCCESS.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_SUCCESS);
    } else if (Look.INFO.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_INFO);
    } else if (Look.WARNING.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_WARNING);
    } else if (Look.DANGER.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_DANGER);
    } else if (Look.DEFAULT.equalsIgnoreCase(lookVal)) {
        link.addAttribute("class", Bootstrap.BUTTON_DEFAULT);
    } else {
        link.addAttribute("class", Bootstrap.BUTTON_LINK);
    }

    appendRefId(link, id);

    StringBuilder urlParams = new StringBuilder("?");
    for (String key : params.keySet()) {
        urlParams.append(key + "=" + params.get(key) + "&");
    }

    String url = "";

    String outcomeVal = WebUtils.decodePath((String) getTagValue(outcome));
    if (outcomeVal != null) {
        url = (outcomeVal.startsWith("/") ? outcomeVal.replaceFirst("/", "") : outcomeVal)
                + urlParams.substring(0, urlParams.length() - 1);
    }

    String href = "#";
    if (action == null && !url.isEmpty()) {
        href = (!url.startsWith("http") && !url.startsWith("mailto") && !url.startsWith("#")
                ? getRequest().getContextPath() + "/"
                : "") + url;
        link.addAttribute("href", href);
    }

    for (IconTagHandler iconTag : iconTags) {
        if (Align.LEFT.equalsIgnoreCase(iconTag.getSide())) {
            link.addTag(iconTag.executeTag());
            link.addText(" ");
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.LEFT.equalsIgnoreCase(imageTag.getSide())) {
            link.addTag(imageTag.executeTag());
            link.addText(" ");
        }
    }

    Object val = getTagValue(label);
    if (val != null && val instanceof String) {
        if (length != null && length > 0 && val.toString().length() >= length) {
            if (ellipsize && length > 4) {
                val = val.toString().substring(0, length - 4) + " ...";
            } else {
                val = val.toString().substring(0, length);
            }
        }
        link.addText((String) val);

    } else if (!sw.toString().isEmpty()) {
        link.addText(sw.toString());
    } else {
        link.addText(href);
    }

    for (IconTagHandler iconTag : iconTags) {
        if (Align.RIGHT.equalsIgnoreCase(iconTag.getSide())) {
            link.addText(" ");
            link.addTag(iconTag.executeTag());
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.RIGHT.equalsIgnoreCase(imageTag.getSide())) {
            link.addText(" ");
            link.addTag(imageTag.executeTag());
        }
    }

    if (Size.XSMALL.equalsIgnoreCase(size)) {
        link.addAttribute("class", Bootstrap.BUTTON_XSMALL);
    } else if (Size.SMALL.equalsIgnoreCase(size)) {
        link.addAttribute("class", Bootstrap.BUTTON_SMALL);
    } else if (Size.LARGE.equalsIgnoreCase(size)) {
        link.addAttribute("class", Bootstrap.BUTTON_LARGE);
    } else if (Size.JUSTIFIED.equalsIgnoreCase(size)) {
        link.addAttribute("class", Bootstrap.BUTTON_JUSTIFIED);
    }

    appendEvent(link);

    if (linkGroup != null) {
        link.addAttribute("data-toggle", "dropdown").addAttribute("class", Bootstrap.DROPDOWN_TOGGLE)
                .addAttribute("class", disabled ? Bootstrap.DISABLED : null).addAttribute("role", "button")
                .addAttribute("aria-expanded", false);

        Span caret = new Span();
        caret.addAttribute("class", Bootstrap.CARET);

        link.addText(" ");
        link.addTag(caret);

        linkGroup.addTag(link);
    }

    // Add the style class at last
    link.addAttribute("class", getTagValue(styleClass));

    if (action != null) {
        appendDocScript(getFunction(url));
    }

    if (loadTag != null) {
        Tag tag = loadTag.executeTag();
        tag.addAttribute("style", "display: none;");
        link.addTag(tag);
    }

    if (dropMenu != null) {
        Tag ul = dropMenu.executeTag();
        ul.addAttribute("class", disabled ? Bootstrap.DISABLED : null);
        linkGroup.addTag(ul);
    }

    appendBind(id);

    if (linkGroup != null) {
        appendTooltip(linkGroup);
        appendPopOver(linkGroup);
    } else {
        appendTooltip(link);
        appendPopOver(link);
    }
    return linkGroup != null ? linkGroup : link;
}

From source file:com.jsmartframework.web.tag.ButtonTagHandler.java

@Override
public Tag executeTag() throws JspException, IOException {
    JspTag parent = getParent();/*from www .  j  av a2  s .  c  o  m*/
    boolean inputAddOn = parent instanceof InputTagHandler || parent instanceof AutoCompleteTagHandler
            || parent instanceof DateTagHandler || parent instanceof SelectTagHandler
            || parent instanceof UploadTagHandler;

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
        body.invoke(null);
    }

    setRandomId("button");

    Div buttonGroup = null;

    if (dropMenu != null || inputAddOn) {
        buttonGroup = new Div();

        if (inputAddOn) {
            buttonGroup.addAttribute("class", Bootstrap.INPUT_GROUP_BUTTON);
        } else {
            buttonGroup.addAttribute("class", Bootstrap.BUTTON_GROUP);
        }

        if (Size.XSMALL.equalsIgnoreCase(size)) {
            buttonGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_XSMALL);
        } else if (Size.SMALL.equalsIgnoreCase(size)) {
            buttonGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_SMALL);
        } else if (Size.LARGE.equalsIgnoreCase(size)) {
            buttonGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_LARGE);
        } else if (Size.JUSTIFIED.name().equalsIgnoreCase(size)) {
            buttonGroup.addAttribute("class", Bootstrap.BUTTON_GROUP_JUSTIFIED);
        }

        if (dropMenu != null && dropMenu.isDropUp()) {
            buttonGroup.addAttribute("class", Bootstrap.DROPUP);
        }
    }

    boolean disabled = isDisabled();

    Button button = new Button();
    button.addAttribute("style", getTagValue(style)).addAttribute("class", Bootstrap.BUTTON)
            .addAttribute("tabindex", tabIndex).addAttribute("disabled", disabled ? "disabled" : null);

    appendRefId(button, id);

    String lookVal = (String) getTagValue(look);
    button.addAttribute("class", getButtonLook(lookVal));

    if (Size.XSMALL.equalsIgnoreCase(size)) {
        button.addAttribute("class", Bootstrap.BUTTON_XSMALL);
    } else if (Size.SMALL.equalsIgnoreCase(size)) {
        button.addAttribute("class", Bootstrap.BUTTON_SMALL);
    } else if (Size.LARGE.equalsIgnoreCase(size)) {
        button.addAttribute("class", Bootstrap.BUTTON_LARGE);
    } else if (Size.JUSTIFIED.equalsIgnoreCase(size)) {
        button.addAttribute("class", Bootstrap.BUTTON_JUSTIFIED);
    }

    for (IconTagHandler iconTag : iconTags) {
        if (Align.LEFT.equalsIgnoreCase(iconTag.getSide())) {
            button.addTag(iconTag.executeTag());
            button.addText(" ");
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.LEFT.equalsIgnoreCase(imageTag.getSide())) {
            button.addTag(imageTag.executeTag());
            button.addText(" ");
        }
    }

    String val = (String) getTagValue(label);
    if (val != null && length != null && length > 0 && val.length() >= length) {
        if (ellipsize && length > 4) {
            val = val.substring(0, length - 4) + " ...";
        } else {
            val = val.substring(0, length);
        }
    }
    button.addText(val);

    for (IconTagHandler iconTag : iconTags) {
        if (Align.RIGHT.equalsIgnoreCase(iconTag.getSide())) {
            button.addText(" ");
            button.addTag(iconTag.executeTag());
        }
    }

    for (ImageTagHandler imageTag : imageTags) {
        if (Align.RIGHT.equalsIgnoreCase(imageTag.getSide())) {
            button.addText(" ");
            button.addTag(imageTag.executeTag());
        }
    }

    if (buttonGroup != null) {
        buttonGroup.addTag(button);
    }

    if (loadTag != null) {
        Tag tag = loadTag.executeTag();
        tag.addAttribute("style", "display: none;");
        button.addTag(tag);
    }

    if (dropMenu != null) {
        Span caret = new Span();
        caret.addAttribute("class", Bootstrap.CARET);

        if (dropMenu.isSegmented()) {
            Button dropDown = new Button();
            dropDown.addAttribute("type", "button").addAttribute("class", Bootstrap.BUTTON)
                    .addAttribute("class", getButtonLook(lookVal)).addAttribute("role", "button")
                    .addAttribute("class", Bootstrap.DROPDOWN_TOGGLE)
                    .addAttribute("class", disabled ? Bootstrap.DISABLED : null)
                    .addAttribute("class", JSmart.BUTTON_DROPDOWN_TOGGLE)
                    .addAttribute("data-toggle", "dropdown").addAttribute("aria-expanded", false);

            dropDown.addText("&zwnj;").addTag(caret);
            buttonGroup.addTag(dropDown);
        } else {
            button.addAttribute("role", "button").addAttribute("class", Bootstrap.DROPDOWN_TOGGLE)
                    .addAttribute("data-toggle", "dropdown").addAttribute("aria-expanded", false);

            button.addText(" ");
            button.addTag(caret);
        }
    }

    // Add the style class at last
    button.addAttribute("class", getTagValue(styleClass));

    appendEvent(button);

    if (ajax) {
        button.addAttribute("type", "button");
    } else if (action != null) {
        button.addAttribute("type", "submit");
    } else if (reset) {
        button.addAttribute("type", "reset");
    } else {
        button.addAttribute("type", "button");
    }

    if (ajax) {
        appendDocScript(getFunction(id, action, params));
    } else if (action != null) {
        button.addAttribute("name", getTagName(J_SBMT, action));
    }

    if (dropMenu != null) {
        Tag ul = dropMenu.executeTag();
        ul.addAttribute("class", disabled ? Bootstrap.DISABLED : null);
        buttonGroup.addTag(ul);
    }

    appendBind(id);
    appendAjax(id);

    if (buttonGroup != null) {
        appendTooltip(buttonGroup);
        appendPopOver(buttonGroup);
    } else {
        appendTooltip(button);
        appendPopOver(button);
    }
    return buttonGroup != null ? buttonGroup : button;
}