Java Code Examples for org.springframework.web.servlet.tags.form.TagWriter#endTag()

The following examples show how to use org.springframework.web.servlet.tags.form.TagWriter#endTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormFirstErrorsTag.java    From bbs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void renderDefaultContent(TagWriter tagWriter) throws JspException {
	tagWriter.startTag(getElement());
	writeDefaultAttributes(tagWriter);
//	String delimiter = ObjectUtils.getDisplayString(evaluate("delimiter", getDelimiter()));
	String[] errorMessages = getBindStatus().getErrorMessages();	
	for (int i = 0; i < errorMessages.length; i++) {
//	for (int i = errorMessages.length-1; i < errorMessages.length; i++) {
		String errorMessage = errorMessages[i];
	//	if (i > 0) {
		//	tagWriter.appendValue(delimiter);//换行
	//	}

		tagWriter.appendValue(getDisplayString(errorMessage));
		break;
	}
	tagWriter.endTag();
}
 
Example 2
Source File: FormErrorsTag.java    From bbs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void renderDefaultContent(TagWriter tagWriter) throws JspException {
	tagWriter.startTag(getElement());
	writeDefaultAttributes(tagWriter);
//	String delimiter = ObjectUtils.getDisplayString(evaluate("delimiter", getDelimiter()));
	String[] errorMessages = getBindStatus().getErrorMessages();	
	for (int i = errorMessages.length-1; i < errorMessages.length; i++) {
		String errorMessage = errorMessages[i];
	//	if (i > 0) {
		//	tagWriter.appendValue(delimiter);//换行
	//	}
		
		tagWriter.appendValue(getDisplayString(errorMessage));
	}
	tagWriter.endTag();
}
 
Example 3
Source File: BSCheckboxesTag.java    From dubai with MIT License 6 votes vote down vote up
@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();
	}

	return SKIP_BODY;
}
 
Example 4
Source File: SessionConversationIdTag.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    
    // first try to pull value from request attribute.
    String conversationId = (String)pageContext.getRequest().getAttribute(attributeName + "_cId");
    
    // if no value was found then try to pull value as request parameter.
    if (conversationId == null || conversationId.trim().length() == 0) {
        conversationId = pageContext.getRequest().getParameter(attributeName + "_cId");
    }
    
    // if a conversation Id was found then process it.
    if (conversationId != null && conversationId.trim().length() > 0) {
        
        // set the request attribute.
        pageContext.getRequest().setAttribute("curr_" + attributeName + "_cId", conversationId);
        
        if (createHiddenInput) {
            // now create the hidden input field.
            tagWriter.startTag("input");
            tagWriter.writeAttribute("type", "hidden");
            tagWriter.writeAttribute("name", attributeName + "_cId");
            tagWriter.writeAttribute("value", conversationId);
            tagWriter.endTag();
        }
    }
    
    return EVAL_PAGE;
}
 
Example 5
Source File: BSAbstractMultiCheckedElementTag.java    From dubai with MIT License 5 votes vote down vote up
/**
 * 重载方法,调整元素的输出顺序。
 */
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();
}