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

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

Introduction

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

Prototype

public void appendValue(String value) throws JspException 

Source Link

Document

Close the current opening tag (if necessary) and appends the supplied value as inner text.

Usage

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

/**
 * Writes the opening '//from  w w w.ja  v  a2 s.c  om
 * <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:com.benfante.taglib.frontend.tags.BootstrapTagHelper.java

/**
 * Writes the opening '/* www.ja va  2 s. 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.jigsforjava.web.tags.form.TextAreaTag.java

private void writeLengthLimitScript(TagWriter writer) throws JspException {
    writer.appendValue("function() { limitLength(");
    writer.appendValue("element, ");
    writer.appendValue(getMaxlength());/*from w  ww .j a v  a  2 s  . com*/
    writer.appendValue("); };");
}

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

/**
  * @param tagWriter/*from  ww w.j  av  a2s .  com*/
  */
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.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  av  a2  s . co 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 ww  . j a v  a  2  s.c om
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();
}

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

/**
 * Writes the opening '<code>label</code>' tag and forces a block tag so
 * that body content is written correctly.
 *///from   w ww. j  a v  a  2s  .  c om
protected void writeLabelTagContent(TagWriter tagWriter) throws JspException {
    String labelText = this.getRequestContext().getMessage(this.label, this.label);
    tagWriter.startTag("label");
    tagWriter.writeAttribute("for", autogenerateFor());
    StringBuilder cssClass = new StringBuilder("form-control-label");
    if (StringUtils.hasText(this.labelCssClass)) {
        cssClass.append(' ').append(this.labelCssClass);
    }
    tagWriter.writeAttribute("class", cssClass.toString());
    tagWriter.appendValue(labelText);
    tagWriter.endTag();
    tagWriter.forceBlock();
}

From source file:org.kmnet.com.fw.web.pagination.PaginationTag.java

/**
 * Renders a anchor.<br>//from w  w  w . ja  va  2 s .c  om
 * @param tagWriter {@code TagWriter} instance that will render the content of the tag to JSP page
 * @param href url of anchor
 * @param value text of anchor
 * @throws JspException
 */
protected void writeAnchor(TagWriter tagWriter, String href, String value) throws JspException {
    if (StringUtils.hasText(href)) {
        tagWriter.startTag(PaginationInfo.A_ELM);
        tagWriter.writeAttribute(PaginationInfo.HREF_ATTR, href);
        tagWriter.appendValue(value);
        tagWriter.endTag();
    } else {
        tagWriter.appendValue(value);
    }
}

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

/**
 * ??//  www. j  a v  a  2  s .co  m
 */
private void writeElementTag(TagWriter tagWriter, Object item, Object value, Object label, int itemIndex)
        throws JspException {
    String id = resolveId();

    String resolvedLabelClass = getInputType();
    if (labelCssClass != null) {
        resolvedLabelClass += " " + labelCssClass;
    }

    tagWriter.startTag("label");
    tagWriter.writeAttribute("for", id);

    tagWriter.writeAttribute("class", resolvedLabelClass);

    if (itemIndex > 0) {
        Object resolvedDelimiter = evaluate("delimiter", getDelimiter());
        if (resolvedDelimiter != null) {
            tagWriter.appendValue(resolvedDelimiter.toString());
        }
    }
    tagWriter.startTag("input");

    writeOptionalAttribute(tagWriter, "id", id);
    writeOptionalAttribute(tagWriter, "name", getName());
    writeOptionalAttributes(tagWriter);
    tagWriter.writeAttribute("type", getInputType());
    renderFromValue(item, value, tagWriter);
    tagWriter.endTag();

    tagWriter.appendValue(convertToDisplayString(label));
    tagWriter.endTag();
}

From source file:org.kmnet.com.fw.web.message.MessagesPanelTag.java

/**
 * writes the message tag.//ww w  .ja  v  a2  s .co m
 * <p>
 * If {@link #innerElement} is specified, the tag specified in it will be
 * applied around the message.<br>
 * </p>
 * 
 * @param tagWriter
 * @param message
 * @throws JspException
 *             Occurs when {@link JspTagException} occurs in case when
 *             nothing is set in the configuration of the tag that
 *             configures MessagePanel using tagWriter.
 */
protected void writeMessage(TagWriter tagWriter, Object message) throws JspException {
    if (message != null) {
        if (StringUtils.hasText(innerElement)) {
            tagWriter.startTag(innerElement); // <li>
        }
        if (disableHtmlEscape) {
            tagWriter.appendValue(getText(message));
        } else {
            tagWriter.appendValue(HtmlEscapeUtils.htmlEscape(getText(message)));
        }

        if (StringUtils.hasText(innerElement)) {
            tagWriter.endTag(); // </li>
        }
    }
}