Skip to content

Commit a778468

Browse files
committed
Consistent JSP tag documentation
Issue: SPR-13520
1 parent 1571829 commit a778468

File tree

8 files changed

+390
-290
lines changed

8 files changed

+390
-290
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentAware.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,4 +33,5 @@ public interface ArgumentAware {
3333
* @param argument the result of the nested {@code spring:argument} tag
3434
*/
3535
void addArgument(Object argument) throws JspTagException;
36+
3637
}

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
2020
import javax.servlet.jsp.tagext.BodyTagSupport;
2121

2222
/**
23-
* JSP tag for collecting arguments and passing them to an {@link ArgumentAware} ancestor
24-
* in the tag hierarchy.
23+
* JSP tag for collecting arguments and passing them to an {@link ArgumentAware}
24+
* ancestor in the tag hierarchy.
2525
*
2626
* <p>This tag must be nested under an argument aware tag.
2727
*
@@ -37,7 +37,17 @@ public class ArgumentTag extends BodyTagSupport {
3737

3838
private boolean valueSet;
3939

40-
// tag lifecycle
40+
41+
/**
42+
* Set the value of the argument (optional).
43+
* <pIf not set, the tag's body content will get evaluated.
44+
* @param value the parameter value
45+
*/
46+
public void setValue(Object value) {
47+
this.value = value;
48+
this.valueSet = true;
49+
}
50+
4151

4252
@Override
4353
public int doEndTag() throws JspException {
@@ -46,38 +56,20 @@ public int doEndTag() throws JspException {
4656
argument = this.value;
4757
}
4858
else if (getBodyContent() != null) {
49-
// get the value from the tag body
59+
// Get the value from the tag body
5060
argument = getBodyContent().getString().trim();
5161
}
5262

53-
// find a param aware ancestor
54-
ArgumentAware argumentAwareTag = (ArgumentAware) findAncestorWithClass(this,
55-
ArgumentAware.class);
63+
// Find a param-aware ancestor
64+
ArgumentAware argumentAwareTag = (ArgumentAware) findAncestorWithClass(this, ArgumentAware.class);
5665
if (argumentAwareTag == null) {
57-
throw new JspException(
58-
"The argument tag must be a descendant of a tag that supports arguments");
66+
throw new JspException("The argument tag must be a descendant of a tag that supports arguments");
5967
}
60-
6168
argumentAwareTag.addArgument(argument);
6269

6370
return EVAL_PAGE;
6471
}
6572

66-
// tag attribute mutators
67-
68-
/**
69-
* Sets the value of the argument
70-
*
71-
* <p>
72-
* Optional. If not set, the tag's body content is evaluated.
73-
*
74-
* @param value the parameter value
75-
*/
76-
public void setValue(Object value) {
77-
this.value = value;
78-
this.valueSet = true;
79-
}
80-
8173
@Override
8274
public void release() {
8375
super.release();

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ParamTag.java

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,22 @@ public class ParamTag extends BodyTagSupport {
4040

4141
private boolean valueSet;
4242

43-
// tag lifecycle
43+
44+
/**
45+
* Set the name of the parameter (required).
46+
*/
47+
public void setName(String name) {
48+
this.name = name;
49+
}
50+
51+
/**
52+
* Set the value of the parameter (optional).
53+
*/
54+
public void setValue(String value) {
55+
this.value = value;
56+
this.valueSet = true;
57+
}
58+
4459

4560
@Override
4661
public int doEndTag() throws JspException {
@@ -50,50 +65,21 @@ public int doEndTag() throws JspException {
5065
param.setValue(this.value);
5166
}
5267
else if (getBodyContent() != null) {
53-
// get the value from the tag body
68+
// Get the value from the tag body
5469
param.setValue(getBodyContent().getString().trim());
5570
}
5671

57-
// find a param aware ancestor
58-
ParamAware paramAwareTag = (ParamAware) findAncestorWithClass(this,
59-
ParamAware.class);
72+
// Find a param aware ancestor
73+
ParamAware paramAwareTag = (ParamAware) findAncestorWithClass(this, ParamAware.class);
6074
if (paramAwareTag == null) {
61-
throw new JspException(
62-
"The param tag must be a descendant of a tag that supports parameters");
75+
throw new JspException("The param tag must be a descendant of a tag that supports parameters");
6376
}
6477

6578
paramAwareTag.addParam(param);
6679

6780
return EVAL_PAGE;
6881
}
6982

70-
// tag attribute accessors
71-
72-
/**
73-
* Sets the name of the parameter
74-
*
75-
* <p>
76-
* Required
77-
*
78-
* @param name the parameter name
79-
*/
80-
public void setName(String name) {
81-
this.name = name;
82-
}
83-
84-
/**
85-
* Sets the value of the parameter
86-
*
87-
* <p>
88-
* Optional. If not set, the tag's body content is evaluated
89-
*
90-
* @param value the parameter value
91-
*/
92-
public void setValue(String value) {
93-
this.value = value;
94-
this.valueSet = true;
95-
}
96-
9783
@Override
9884
public void release() {
9985
super.release();

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -194,15 +194,18 @@ protected String getAction() {
194194
}
195195

196196
/**
197-
* Set the value of the '{@code action}' attribute.
197+
* Set the value of the '{@code action}' attribute through a value
198+
* that is to be appended to the current servlet path.
198199
* <p>May be a runtime expression.
200+
* @since 3.2.3
199201
*/
200-
public void setServletRelativeAction(String servletRelativeaction) {
201-
this.servletRelativeAction = (servletRelativeaction != null ? servletRelativeaction : "");
202+
public void setServletRelativeAction(String servletRelativeAction) {
203+
this.servletRelativeAction = (servletRelativeAction != null ? servletRelativeAction : "");
202204
}
203205

204206
/**
205-
* Get the value of the '{@code action}' attribute.
207+
* Get the servlet-relative value of the '{@code action}' attribute.
208+
* @since 3.2.3
206209
*/
207210
protected String getServletRelativeAction() {
208211
return this.servletRelativeAction;
@@ -322,7 +325,19 @@ public void setMethodParam(String methodParam) {
322325

323326
/**
324327
* Get the name of the request param for non-browser supported HTTP methods.
328+
* @since 4.2.3
329+
*/
330+
@SuppressWarnings("deprecation")
331+
protected String getMethodParam() {
332+
return getMethodParameter();
333+
}
334+
335+
/**
336+
* Get the name of the request param for non-browser supported HTTP methods.
337+
* @deprecated as of 4.2.3, in favor of {@link #getMethodParam()} which is
338+
* a proper pairing for {@link #setMethodParam(String)}
325339
*/
340+
@Deprecated
326341
protected String getMethodParameter() {
327342
return this.methodParam;
328343
}
@@ -334,6 +349,7 @@ protected boolean isMethodBrowserSupported(String method) {
334349
return ("get".equalsIgnoreCase(method) || "post".equalsIgnoreCase(method));
335350
}
336351

352+
337353
/**
338354
* Writes the opening part of the block '{@code form}' tag and exposes
339355
* the form object name in the {@link javax.servlet.jsp.PageContext}.
@@ -359,7 +375,7 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
359375

360376
if (!isMethodBrowserSupported(getMethod())) {
361377
assertHttpMethod(getMethod());
362-
String inputName = getMethodParameter();
378+
String inputName = getMethodParam();
363379
String inputType = "hidden";
364380
tagWriter.startTag(INPUT_TAG);
365381
writeOptionalAttribute(tagWriter, TYPE_ATTRIBUTE, inputType);

0 commit comments

Comments
 (0)