org.springframework.web.util.TagUtils Java Examples

The following examples show how to use org.springframework.web.util.TagUtils. 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: TransformTag.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected final int doStartTagInternal() throws JspException {
	if (this.value != null) {
		// Find the containing EditorAwareTag (e.g. BindTag), if applicable.
		EditorAwareTag tag = (EditorAwareTag) TagSupport.findAncestorWithClass(this, EditorAwareTag.class);
		if (tag == null) {
			throw new JspException("TransformTag can only be used within EditorAwareTag (e.g. BindTag)");
		}

		// OK, let's obtain the editor...
		String result = null;
		PropertyEditor editor = tag.getEditor();
		if (editor != null) {
			// If an editor was found, edit the value.
			editor.setValue(this.value);
			result = editor.getAsText();
		}
		else {
			// Else, just do a toString.
			result = this.value.toString();
		}
		result = htmlEscape(result);
		if (this.var != null) {
			pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
		}
		else {
			try {
				// Else, just print it out.
				pageContext.getOut().print(result);
			}
			catch (IOException ex) {
				throw new JspException(ex);
			}
		}
	}

	return SKIP_BODY;
}
 
Example #2
Source File: TransformTag.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected final int doStartTagInternal() throws JspException {
	if (this.value != null) {
		// Find the containing EditorAwareTag (e.g. BindTag), if applicable.
		EditorAwareTag tag = (EditorAwareTag) TagSupport.findAncestorWithClass(this, EditorAwareTag.class);
		if (tag == null) {
			throw new JspException("TransformTag can only be used within EditorAwareTag (e.g. BindTag)");
		}

		// OK, let's obtain the editor...
		String result = null;
		PropertyEditor editor = tag.getEditor();
		if (editor != null) {
			// If an editor was found, edit the value.
			editor.setValue(this.value);
			result = editor.getAsText();
		}
		else {
			// Else, just do a toString.
			result = this.value.toString();
		}
		result = htmlEscape(result);
		if (this.var != null) {
			this.pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
		}
		else {
			try {
				// Else, just print it out.
				this.pageContext.getOut().print(result);
			}
			catch (IOException ex) {
				throw new JspException(ex);
			}
		}
	}

	return SKIP_BODY;
}
 
Example #3
Source File: TransformTag.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected final int doStartTagInternal() throws JspException {
	if (this.value != null) {
		// Find the containing EditorAwareTag (e.g. BindTag), if applicable.
		EditorAwareTag tag = (EditorAwareTag) TagSupport.findAncestorWithClass(this, EditorAwareTag.class);
		if (tag == null) {
			throw new JspException("TransformTag can only be used within EditorAwareTag (e.g. BindTag)");
		}

		// OK, let's obtain the editor...
		String result = null;
		PropertyEditor editor = tag.getEditor();
		if (editor != null) {
			// If an editor was found, edit the value.
			editor.setValue(this.value);
			result = editor.getAsText();
		}
		else {
			// Else, just do a toString.
			result = this.value.toString();
		}
		result = htmlEscape(result);
		if (this.var != null) {
			pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
		}
		else {
			try {
				// Else, just print it out.
				pageContext.getOut().print(result);
			}
			catch (IOException ex) {
				throw new JspException(ex);
			}
		}
	}

	return SKIP_BODY;
}
 
Example #4
Source File: TransformTag.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected final int doStartTagInternal() throws JspException {
	if (this.value != null) {
		// Find the containing EditorAwareTag (e.g. BindTag), if applicable.
		EditorAwareTag tag = (EditorAwareTag) TagSupport.findAncestorWithClass(this, EditorAwareTag.class);
		if (tag == null) {
			throw new JspException("TransformTag can only be used within EditorAwareTag (e.g. BindTag)");
		}

		// OK, let's obtain the editor...
		String result = null;
		PropertyEditor editor = tag.getEditor();
		if (editor != null) {
			// If an editor was found, edit the value.
			editor.setValue(this.value);
			result = editor.getAsText();
		}
		else {
			// Else, just do a toString.
			result = this.value.toString();
		}
		result = htmlEscape(result);
		if (this.var != null) {
			this.pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
		}
		else {
			try {
				// Else, just print it out.
				this.pageContext.getOut().print(result);
			}
			catch (IOException ex) {
				throw new JspException(ex);
			}
		}
	}

	return SKIP_BODY;
}
 
Example #5
Source File: OptionsTag.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private SelectTag getSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "options", "select");
	return (SelectTag) findAncestorWithClass(this, SelectTag.class);
}
 
Example #6
Source File: OptionTag.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void assertUnderSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "option", "select");
}
 
Example #7
Source File: OptionsTag.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private SelectTag getSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "options", "select");
	return (SelectTag) findAncestorWithClass(this, SelectTag.class);
}
 
Example #8
Source File: OptionTag.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void assertUnderSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "option", "select");
}
 
Example #9
Source File: OptionsTag.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private SelectTag getSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "options", "select");
	return (SelectTag) findAncestorWithClass(this, SelectTag.class);
}
 
Example #10
Source File: OptionTag.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void assertUnderSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "option", "select");
}
 
Example #11
Source File: OptionsTag.java    From java-technology-stack with MIT License 4 votes vote down vote up
private SelectTag getSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "options", "select");
	return (SelectTag) findAncestorWithClass(this, SelectTag.class);
}
 
Example #12
Source File: OptionTag.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void assertUnderSelectTag() {
	TagUtils.assertHasAncestorOfType(this, SelectTag.class, "option", "select");
}
 
Example #13
Source File: EvalTag.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the scope to export the evaluation result to.
 * This attribute has no meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #14
Source File: UrlTag.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the scope to export the URL variable to. This attribute has no
 * meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #15
Source File: UrlTag.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the scope to export the URL variable to. This attribute has no
 * meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #16
Source File: EvalTag.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the scope to export the evaluation result to.
 * This attribute has no meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #17
Source File: EvalTag.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the scope to export the evaluation result to.
 * This attribute has no meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #18
Source File: UrlTag.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the scope to export the URL variable to. This attribute has no
 * meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #19
Source File: UrlTag.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the scope to export the URL variable to. This attribute has no
 * meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}
 
Example #20
Source File: EvalTag.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the scope to export the evaluation result to.
 * This attribute has no meaning unless var is also defined.
 */
public void setScope(String scope) {
	this.scope = TagUtils.getScope(scope);
}