You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ma...@apache.org on 2002/08/06 05:47:10 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html FormTag.java
martinc 2002/08/05 20:47:10
Modified: src/share/org/apache/struts/taglib/html FormTag.java
Log:
Fix lots of indentation inconsistencies that were bugging me, and add some
missing braces around 'if' statements. No real code changes.
Revision Changes Path
1.25 +117 -112 jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java
Index: FormTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- FormTag.java 9 Jul 2002 23:58:52 -0000 1.24
+++ FormTag.java 6 Aug 2002 03:47:10 -0000 1.25
@@ -131,7 +131,8 @@
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
+ MessageResources.getMessageResources(
+ Constants.Package + ".LocalStrings");
/**
@@ -229,7 +230,7 @@
*/
public String getAction() {
- return (this.action);
+ return (this.action);
}
@@ -241,7 +242,7 @@
*/
public void setAction(String action) {
- this.action = action;
+ this.action = action;
}
@@ -250,7 +251,7 @@
*/
public String getEnctype() {
- return (this.enctype);
+ return (this.enctype);
}
@@ -261,7 +262,7 @@
*/
public void setEnctype(String enctype) {
- this.enctype = enctype;
+ this.enctype = enctype;
}
@@ -270,7 +271,7 @@
*/
public String getFocus() {
- return (this.focus);
+ return (this.focus);
}
@@ -282,7 +283,7 @@
*/
public void setFocus(String focus) {
- this.focus = focus;
+ this.focus = focus;
}
@@ -292,7 +293,7 @@
*/
public String getMethod() {
- return (this.method);
+ return (this.method);
}
@@ -304,7 +305,7 @@
*/
public void setMethod(String method) {
- this.method = method;
+ this.method = method;
}
@@ -314,7 +315,7 @@
*/
public String getName() {
- return (this.name);
+ return (this.name);
}
@@ -326,7 +327,7 @@
*/
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -336,7 +337,7 @@
*/
public String getOnreset() {
- return (this.onreset);
+ return (this.onreset);
}
@@ -348,7 +349,7 @@
*/
public void setOnreset(String onReset) {
- this.onreset = onReset;
+ this.onreset = onReset;
}
@@ -358,7 +359,7 @@
*/
public String getOnsubmit() {
- return (this.onsubmit);
+ return (this.onsubmit);
}
@@ -370,7 +371,7 @@
*/
public void setOnsubmit(String onSubmit) {
- this.onsubmit = onSubmit;
+ this.onsubmit = onSubmit;
}
@@ -380,7 +381,7 @@
*/
public String getScope() {
- return (this.scope);
+ return (this.scope);
}
@@ -392,7 +393,7 @@
*/
public void setScope(String scope) {
- this.scope = scope;
+ this.scope = scope;
}
@@ -402,7 +403,7 @@
*/
public String getStyle() {
- return (this.style);
+ return (this.style);
}
@@ -414,7 +415,7 @@
*/
public void setStyle(String style) {
- this.style = style;
+ this.style = style;
}
@@ -424,7 +425,7 @@
*/
public String getStyleClass() {
- return (this.styleClass);
+ return (this.styleClass);
}
@@ -436,7 +437,7 @@
*/
public void setStyleClass(String styleClass) {
- this.styleClass = styleClass;
+ this.styleClass = styleClass;
}
@@ -469,7 +470,7 @@
*/
public String getTarget() {
- return (this.target);
+ return (this.target);
}
@@ -481,7 +482,7 @@
*/
public void setTarget(String target) {
- this.target = target;
+ this.target = target;
}
@@ -491,7 +492,7 @@
*/
public String getType() {
- return (this.type);
+ return (this.type);
}
@@ -503,7 +504,7 @@
*/
public void setType(String type) {
- this.type = type;
+ this.type = type;
}
@@ -527,15 +528,15 @@
// Look up the form bean name, scope, and type if necessary
lookup();
- // Create an appropriate "form" element based on our parameters
- HttpServletResponse response =
- (HttpServletResponse) pageContext.getResponse();
- StringBuffer results = new StringBuffer("<form");
- results.append(" name=\"");
- results.append(name);
- results.append("\"");
- results.append(" method=\"");
- results.append(method);
+ // Create an appropriate "form" element based on our parameters
+ HttpServletResponse response =
+ (HttpServletResponse) pageContext.getResponse();
+ StringBuffer results = new StringBuffer("<form");
+ results.append(" name=\"");
+ results.append(name);
+ results.append("\"");
+ results.append(" method=\"");
+ results.append(method);
results.append("\" action=\"");
results.append(response.encodeURL(getActionMappingURL()));
results.append("\"");
@@ -544,21 +545,21 @@
results.append(styleClass);
results.append("\"");
}
- if (enctype != null) {
- results.append(" enctype=\"");
- results.append(enctype);
- results.append("\"");
- }
- if (onreset != null) {
- results.append(" onreset=\"");
- results.append(onreset);
- results.append("\"");
+ if (enctype != null) {
+ results.append(" enctype=\"");
+ results.append(enctype);
+ results.append("\"");
+ }
+ if (onreset != null) {
+ results.append(" onreset=\"");
+ results.append(onreset);
+ results.append("\"");
}
if (onsubmit != null) {
- results.append(" onsubmit=\"");
- results.append(onsubmit);
- results.append("\"");
- }
+ results.append(" onsubmit=\"");
+ results.append(onsubmit);
+ results.append("\"");
+ }
if (style != null) {
results.append(" style=\"");
results.append(style);
@@ -569,12 +570,12 @@
results.append(styleId);
results.append("\"");
}
- if (target != null) {
- results.append(" target=\"");
- results.append(target);
- results.append("\"");
- }
- results.append(">");
+ if (target != null) {
+ results.append(" target=\"");
+ results.append(target);
+ results.append("\"");
+ }
+ results.append(">");
// Add a transaction token (if present in our session)
HttpSession session = pageContext.getSession();
@@ -590,19 +591,20 @@
}
}
- // Print this field to our output writer
+ // Print this field to our output writer
ResponseUtils.write(pageContext, results.toString());
- // Store this tag itself as a page attribute
- pageContext.setAttribute(Constants.FORM_KEY, this,
+ // Store this tag itself as a page attribute
+ pageContext.setAttribute(Constants.FORM_KEY, this,
PageContext.REQUEST_SCOPE);
- // Locate or create the bean associated with our form
- int scope = PageContext.SESSION_SCOPE;
- if ("request".equals(this.scope))
- scope = PageContext.REQUEST_SCOPE;
- Object bean = pageContext.getAttribute(name, scope);
- if (bean == null) {
+ // Locate or create the bean associated with our form
+ int scope = PageContext.SESSION_SCOPE;
+ if ("request".equals(this.scope)) {
+ scope = PageContext.REQUEST_SCOPE;
+ }
+ Object bean = pageContext.getAttribute(name, scope);
+ if (bean == null) {
bean = RequestUtils.createActionForm
((HttpServletRequest) pageContext.getRequest(),
mapping, appConfig, servlet);
@@ -616,11 +618,11 @@
}
pageContext.setAttribute(name, bean, scope);
}
- pageContext.setAttribute(Constants.BEAN_KEY, bean,
+ pageContext.setAttribute(Constants.BEAN_KEY, bean,
PageContext.REQUEST_SCOPE);
- // Continue processing this page
- return (EVAL_BODY_INCLUDE);
+ // Continue processing this page
+ return (EVAL_BODY_INCLUDE);
}
@@ -632,17 +634,17 @@
*/
public int doEndTag() throws JspException {
- // Remove the page scope attributes we created
- pageContext.removeAttribute(Constants.BEAN_KEY,
+ // Remove the page scope attributes we created
+ pageContext.removeAttribute(Constants.BEAN_KEY,
PageContext.REQUEST_SCOPE);
- pageContext.removeAttribute(Constants.FORM_KEY,
+ pageContext.removeAttribute(Constants.FORM_KEY,
PageContext.REQUEST_SCOPE);
- // Render a tag representing the end of our current form
- StringBuffer results = new StringBuffer("</form>");
+ // Render a tag representing the end of our current form
+ StringBuffer results = new StringBuffer("</form>");
// Render JavaScript to set the input focus if required
- if (focus != null) {
+ if (focus != null) {
String tempFocus = focus;
StringBuffer refocus = new StringBuffer("[");
if (tempFocus.indexOf("[") > 0) {
@@ -652,10 +654,10 @@
refocus.append(st.nextToken());
}
}
- results.append("\r\n");
- results.append("<script language=\"JavaScript\"");
+ results.append("\r\n");
+ results.append("<script language=\"JavaScript\"");
results.append(" type=\"text/javascript\">\r\n");
- results.append(" <!--\r\n");
+ results.append(" <!--\r\n");
results.append(" if (document.forms[\"");
results.append(name);
results.append("\"].elements[\"");
@@ -665,27 +667,27 @@
results.append(refocus.toString());
}
results.append(".type != \"hidden\") \r\n");
- results.append(" document.forms[\"");
- results.append(name);
- results.append("\"].elements[\"");
+ results.append(" document.forms[\"");
+ results.append(name);
+ results.append("\"].elements[\"");
results.append(tempFocus);
results.append("\"]");
if (refocus.length() > 1) {
results.append(refocus.toString());
}
- results.append(".focus()\r\n");
- results.append(" // -->\r\n");
- results.append("</script>\r\n");
- }
+ results.append(".focus()\r\n");
+ results.append(" // -->\r\n");
+ results.append("</script>\r\n");
+ }
- // Print this value to our output writer
- JspWriter writer = pageContext.getOut();
- try {
- writer.print(results.toString());
- } catch (IOException e) {
- throw new JspException
- (messages.getMessage("common.io", e.toString()));
- }
+ // Print this value to our output writer
+ JspWriter writer = pageContext.getOut();
+ try {
+ writer.print(results.toString());
+ } catch (IOException e) {
+ throw new JspException
+ (messages.getMessage("common.io", e.toString()));
+ }
// Restore original property values used to invoke this tag. Needed
// for tag reuse to work correctly.
@@ -693,8 +695,8 @@
scope = savedScope;
type = savedType;
- // Continue processing this page
- return (EVAL_PAGE);
+ // Continue processing this page
+ return (EVAL_PAGE);
}
@@ -704,23 +706,23 @@
*/
public void release() {
- super.release();
- action = null;
+ super.release();
+ action = null;
appConfig = null;
- enctype = null;
- focus = null;
+ enctype = null;
+ focus = null;
mapping = null;
- method = "POST";
- name = null;
- onreset = null;
- onsubmit = null;
- scope = "session";
+ method = "POST";
+ name = null;
+ onreset = null;
+ onsubmit = null;
+ scope = "session";
servlet = null;
- style = null;
- styleClass = null;
+ style = null;
+ styleClass = null;
styleId = null;
- target = null;
- type = null;
+ target = null;
+ type = null;
}
@@ -743,16 +745,19 @@
String value = action;
int question = action.indexOf("?");
- if (question >= 0)
+ if (question >= 0) {
value = value.substring(0, question);
+ }
int slash = value.lastIndexOf("/");
int period = value.lastIndexOf(".");
- if ((period >= 0) && (period > slash))
+ if ((period >= 0) && (period > slash)) {
value = value.substring(0, period);
- if (value.startsWith("/"))
+ }
+ if (value.startsWith("/")) {
return (value);
- else
+ } else {
return ("/" + value);
+ }
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>