Example usage for org.springframework.web.servlet.tags.form TagWriter startTag

List of usage examples for org.springframework.web.servlet.tags.form TagWriter startTag

Introduction

In this page you can find the example usage for org.springframework.web.servlet.tags.form TagWriter startTag.

Prototype

public void startTag(String tagName) throws JspException 

Source Link

Document

Start a new tag with the supplied name.

Usage

From source file:com.benfante.taglib.frontend.tags.BootstrapTagHelper.java

/**
 * Writes the opening '//from   w w w.j  a  v  a  2s . c o  m
 * <code>span</code>' tag and forces a block tag so that field prefix/suffix
 * is written correctly.
 */
public static void writeInputTagDecorator(final TagWriter tagWriter, final String text) throws JspException {
    if (StringUtils.hasText(text)) {
        tagWriter.startTag("span");
        tagWriter.writeAttribute("class", "input-group-addon");
        tagWriter.appendValue(text);
        tagWriter.endTag();
        tagWriter.forceBlock();
    }
}

From source file:com.benfante.taglib.frontend.tags.BootstrapTagHelper.java

/**
 * Writes the opening '//from   www . j  a  v  a 2s .c  o  m
 * <code>p</code>' tag and forces a block tag so that field prefix/suffix is
 * written correctly.
 */
public static void writeInputTagHelpBlock(final TagWriter tagWriter, final String text) throws JspException {
    if (StringUtils.hasText(text)) {
        tagWriter.startTag("p");
        tagWriter.writeAttribute("class", "help-block");
        tagWriter.appendValue(text);
        tagWriter.endTag();
        tagWriter.forceBlock();
    }
}

From source file:org.hdiv.web.servlet.tags.form.HiddenInputTagHDIV.java

/**
 * Writes the HTML '<code>input</code>' tag to the supplied
 * {@link TagWriter} including the databound value.
 * //from   w  w  w . j a va 2s .c  o m
 * @see #writeDefaultAttributes(TagWriter)
 * @see #getBoundValue()
 */
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    tagWriter.startTag("input");
    writeDefaultAttributes(tagWriter);
    tagWriter.writeAttribute("type", "hidden");

    String displayValue = getDisplayString(getBoundValue(), getPropertyEditor());
    String displayName = getDisplayString(evaluate("name", getName()));

    IDataComposer dataComposer = (IDataComposer) this.pageContext.getRequest()
            .getAttribute(TagUtils.DATA_COMPOSER);
    String hdivValue = dataComposer.compose(displayName, displayValue, false);

    tagWriter.writeAttribute("value", hdivValue);
    tagWriter.endTag();

    return SKIP_BODY;
}

From source file:com.benfante.taglib.frontend.tags.LabelledOutputTag.java

@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    tagWriter.startTag("div");
    tagWriter.writeAttribute("class", "row");

    writeLabelTagContent(tagWriter);//  ww  w.java2  s.  com
    tagWriter.startTag("output");
    tagWriter.writeAttribute("class", this.getCssClass());
    tagWriter.forceBlock();
    this.tagWriter = tagWriter;
    return EVAL_BODY_INCLUDE;
}

From source file:org.hdiv.web.servlet.tags.form.SubmitTagHDIV.java

/**
 * Writes the '<code>input</code>' tag to the supplied {@link TagWriter}.
 * Uses the value returned by {@link #getType()} to determine which
 * type of '<code>input</code>' element to render.
 *///from  ww w.  j  av a 2s.c o  m
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {

    tagWriter.startTag("input");

    writeDefaultAttributes(tagWriter);
    tagWriter.writeAttribute("type", getType());
    writeValue(tagWriter);

    tagWriter.endTag();
    return EVAL_PAGE;
}

From source file:com.jigsforjava.web.tags.form.TextAreaTag.java

/**
  * @param tagWriter/*from w w w. j a v  a  2  s  . co m*/
  */
private void writeMaxLengthScript(TagWriter writer) throws JspException {
    String elementId = createPath();
    writer.startTag("script");
    writeOptionalAttribute(writer, "type", "text/javascript");
    writer.appendValue("var element = ");
    writer.appendValue(asElement(elementId));
    writer.appendValue(";");
    writer.appendValue("element.onchange=");
    writeLengthLimitScript(writer);

    writer.appendValue("element.onkeyup=");
    writeLengthLimitScript(writer);
    writer.endTag();
}

From source file:com.benfante.taglib.frontend.tags.PasswordInputTag.java

@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    tagWriter.startTag("div");
    if (this.getBindStatus().isError()) {
        tagWriter.writeAttribute("class", "control-group error");
    } else {/*from w w  w .j a  v  a  2 s  . c o m*/
        tagWriter.writeAttribute("class", "control-group");
    }
    writeLabelTagContent(tagWriter);
    tagWriter.startTag("div");
    tagWriter.writeAttribute("class", "controls");
    String cssClasses = BootstrapTagHelper.prependAppendCssClasses(prefix, suffix);
    if (StringUtils.hasText(cssClasses)) {
        tagWriter.startTag("div");
        tagWriter.writeAttribute("class", cssClasses);
        BootstrapTagHelper.writeInputTagDecorator(tagWriter, prefix);
    }
    super.writeTagContent(tagWriter);
    if (StringUtils.hasText(cssClasses)) {
        BootstrapTagHelper.writeInputTagDecorator(tagWriter, suffix);
        tagWriter.endTag();
    }
    if (this.getBindStatus().isError()) {
        tagWriter.startTag("span");
        tagWriter.writeAttribute("id", autogenerateErrorId());
        tagWriter.writeAttribute("class", "help-inline");
        // writeDefaultAttributes(tagWriter);
        String delimiter = "<br/>";
        String[] errorMessages = getBindStatus().getErrorMessages();
        for (int i = 0; i < errorMessages.length; i++) {
            String errorMessage = errorMessages[i];
            if (i > 0) {
                tagWriter.appendValue(delimiter);
            }
            tagWriter.appendValue(getDisplayString(errorMessage));
        }
        tagWriter.endTag();
    }
    BootstrapTagHelper.writeInputTagHelpBlock(tagWriter, help);
    tagWriter.endTag();
    tagWriter.endTag();
    return SKIP_BODY;
}

From source file:com.xyxy.platform.modules.core.web.taglib.BSCheckboxesTag.java

@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    super.writeTagContent(tagWriter);

    if (!isDisabled()) {
        // Write out the 'field was present' marker.
        tagWriter.startTag("input");
        tagWriter.writeAttribute("type", "hidden");
        String name = WebDataBinder.DEFAULT_FIELD_MARKER_PREFIX + getName();
        tagWriter.writeAttribute("name", name);
        tagWriter.writeAttribute("value", processFieldValue(name, "on", getInputType()));
        tagWriter.endTag();//from   w w w . j  a va2 s  .c  o  m
    }

    return SKIP_BODY;
}

From source file:com.benfante.taglib.frontend.tags.LabelledOutputTag.java

/**
 * Writes the opening '<code>label</code>' tag and forces a block tag so
 * that body content is written correctly.
 *///from ww  w. j  a  va2  s.  c o m
protected void writeLabelTagContent(TagWriter tagWriter) throws JspException {
    String labelText = this.getRequestContext().getMessage(this.label, this.label);
    tagWriter.startTag("label");
    tagWriter.writeAttribute("class", this.getLabelCssClass() + " font-weight-bold");
    tagWriter.appendValue(labelText);
    tagWriter.endTag();
}

From source file:com.benfante.taglib.frontend.tags.PasswordInputTag.java

/**
 * Writes the opening '<code>label</code>' tag and forces a block tag so
 * that body content is written correctly.
 *//*from   w  w  w  .  j a  va  2  s  .  c  o  m*/
protected void writeLabelTagContent(TagWriter tagWriter) throws JspException {
    String labelText = this.getRequestContext().getMessage(this.label, this.label);
    tagWriter.startTag("label");
    tagWriter.writeAttribute("for", autogenerateFor());
    tagWriter.writeAttribute("class", "control-label");
    tagWriter.appendValue(labelText);
    tagWriter.endTag();
    tagWriter.forceBlock();
}