You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 22:00:55 UTC
svn commit: r376840 [1/2] -
/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/
Author: husted
Date: Fri Feb 10 13:00:51 2006
New Revision: 376840
URL: http://svn.apache.org/viewcvs?rev=376840&view=rev
Log:
Checkstyle Roundup
* Taglib bean package reformatted with latest Jalopy settings. Stylistic changes only.
Modified:
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/MessageTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/StrutsTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/StrutsTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/WriteTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/package.html
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTag.java Fri Feb 10 13:00:51 2006
@@ -1,53 +1,71 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
-import java.util.ArrayList;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
+import java.util.ArrayList;
/**
- * Define a scripting variable based on the value(s) of the specified
- * cookie received with this request.
+ * Define a scripting variable based on the value(s) of the specified cookie
+ * received with this request.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class CookieTag extends TagSupport {
-
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
-
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * Return an array of Cookies if <code>multiple</code> is non-null.
+ */
+ protected String multiple = null;
+
+ /**
+ * The name of the cookie whose value is to be exposed.
+ */
+ protected String name = null;
+
+ /**
+ * The default value to return if no cookie of the specified name is
+ * found.
+ */
+ protected String value = null;
+
public String getId() {
return (this.id);
}
@@ -56,20 +74,6 @@
this.id = id;
}
-
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
-
- /**
- * Return an array of Cookies if <code>multiple</code> is non-null.
- */
- protected String multiple = null;
-
public String getMultiple() {
return (this.multiple);
}
@@ -78,12 +82,6 @@
this.multiple = multiple;
}
-
- /**
- * The name of the cookie whose value is to be exposed.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -92,12 +90,6 @@
this.name = name;
}
-
- /**
- * The default value to return if no cookie of the specified name is found.
- */
- protected String value = null;
-
public String getValue() {
return (this.value);
}
@@ -106,33 +98,37 @@
this.value = value;
}
-
// --------------------------------------------------------- Public Methods
-
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
// Retrieve the required cookie value(s)
ArrayList values = new ArrayList();
- Cookie cookies[] =
+ Cookie[] cookies =
((HttpServletRequest) pageContext.getRequest()).getCookies();
- if (cookies == null)
+
+ if (cookies == null) {
cookies = new Cookie[0];
+ }
for (int i = 0; i < cookies.length; i++) {
- if (name.equals(cookies[i].getName()))
+ if (name.equals(cookies[i].getName())) {
values.add(cookies[i]);
+ }
}
- if ((values.size() < 1) && (value != null))
+
+ if ((values.size() < 1) && (value != null)) {
values.add(new Cookie(name, value));
+ }
+
if (values.size() < 1) {
- JspException e = new JspException
- (messages.getMessage("cookie.get", name));
+ JspException e =
+ new JspException(messages.getMessage("cookie.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
@@ -140,28 +136,24 @@
// Expose an appropriate variable containing these results
if (multiple == null) {
Cookie cookie = (Cookie) values.get(0);
+
pageContext.setAttribute(id, cookie);
} else {
cookies = new Cookie[values.size()];
pageContext.setAttribute(id, values.toArray(cookies));
}
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
-
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
id = null;
multiple = null;
name = null;
value = null;
-
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/CookieTei.java Fri Feb 10 13:00:51 2006
@@ -1,58 +1,49 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>cookie</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>cookie</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class CookieTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
String className = null;
- if (data.getAttribute("multiple") == null)
+
+ if (data.getAttribute("multiple") == null) {
className = "javax.servlet.http.Cookie";
- else
+ } else {
className = "javax.servlet.http.Cookie[]";
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- className,
- true,
- VariableInfo.AT_BEGIN)
- };
+ }
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), className, true,
+ VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTag.java Fri Feb 10 13:00:51 2006
@@ -1,48 +1,43 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.struts.taglib.TagUtils;
-import org.apache.struts.util.MessageResources;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
/**
- * Define a scripting variable based on the value(s) of the specified
- * bean property.
+ * Define a scripting variable based on the value(s) of the specified bean
+ * property.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-15 12:16:32 -0400 (Wed, 15 Jun 2005)
+ * $
*/
-
public class DefineTag extends BodyTagSupport {
-
/**
- * Commons logging instance.
- */
- private static final Log log = LogFactory.getLog(DefineTag.class);
+ * Commons logging instance.
+ */
+ private static final Log log = LogFactory.getLog(DefineTag.class);
// ---------------------------------------------------- Protected variables
@@ -50,25 +45,52 @@
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
/**
* The body content of this tag (if any).
*/
protected String body = null;
-
// ------------------------------------------------------------- Properties
-
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * The name of the bean owning the property to be exposed.
+ */
+ protected String name = null;
+
+ /**
+ * The name of the property to be retrieved.
+ */
+ protected String property = null;
+
+ /**
+ * The scope within which to search for the specified bean.
+ */
+ protected String scope = null;
+
+ /**
+ * The scope within which the newly defined bean will be creatd.
+ */
+ protected String toScope = null;
+
+ /**
+ * The fully qualified Java class name of the value to be exposed.
+ */
+ protected String type = null;
+
+ /**
+ * The (String) value to which the defined bean will be set.
+ */
+ protected String value = null;
+
public String getId() {
return (this.id);
}
@@ -77,12 +99,6 @@
this.id = id;
}
-
- /**
- * The name of the bean owning the property to be exposed.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -91,12 +107,6 @@
this.name = name;
}
-
- /**
- * The name of the property to be retrieved.
- */
- protected String property = null;
-
public String getProperty() {
return (this.property);
}
@@ -105,12 +115,6 @@
this.property = property;
}
-
- /**
- * The scope within which to search for the specified bean.
- */
- protected String scope = null;
-
public String getScope() {
return (this.scope);
}
@@ -119,12 +123,6 @@
this.scope = scope;
}
-
- /**
- * The scope within which the newly defined bean will be creatd.
- */
- protected String toScope = null;
-
public String getToScope() {
return (this.toScope);
}
@@ -133,12 +131,6 @@
this.toScope = toScope;
}
-
- /**
- * The fully qualified Java class name of the value to be exposed.
- */
- protected String type = null;
-
public String getType() {
return (this.type);
}
@@ -147,12 +139,6 @@
this.type = type;
}
-
- /**
- * The (String) value to which the defined bean will be set.
- */
- protected String value = null;
-
public String getValue() {
return (this.value);
}
@@ -161,106 +147,109 @@
this.value = value;
}
-
// --------------------------------------------------------- Public Methods
-
/**
* Check if we need to evaluate the body of the tag
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
return (EVAL_BODY_TAG);
-
}
-
/**
- * Save the body content of this tag (if any), or throw a JspException
- * if the value was already defined.
+ * Save the body content of this tag (if any), or throw a JspException if
+ * the value was already defined.
*
- * @exception JspException if value was defined by an attribute
+ * @throws JspException if value was defined by an attribute
*/
public int doAfterBody() throws JspException {
-
if (bodyContent != null) {
body = bodyContent.getString();
+
if (body != null) {
body = body.trim();
}
+
if (body.length() < 1) {
body = null;
}
}
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
-
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
-
// Enforce restriction on ways to declare the new value
int n = 0;
+
if (this.body != null) {
n++;
}
+
if (this.name != null) {
n++;
}
+
if (this.value != null) {
n++;
}
+
if (n > 1) {
JspException e =
new JspException(messages.getMessage("define.value", id));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Retrieve the required property value
Object value = this.value;
+
if ((value == null) && (name != null)) {
- value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
+ value =
+ TagUtils.getInstance().lookup(pageContext, name, property, scope);
}
+
if ((value == null) && (body != null)) {
value = body;
}
+
if (value == null) {
JspException e =
new JspException(messages.getMessage("define.null", id));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Expose this value as a scripting variable
int inScope = PageContext.PAGE_SCOPE;
+
try {
- if (toScope != null) {
- inScope = TagUtils.getInstance().getScope(toScope);
- }
- } catch (JspException e) {
+ if (toScope != null) {
+ inScope = TagUtils.getInstance().getScope(toScope);
+ }
+ } catch (JspException e) {
log.warn("toScope was invalid name so we default to PAGE_SCOPE", e);
- }
-
+ }
+
pageContext.setAttribute(id, value, inScope);
// Continue processing this page
return (EVAL_PAGE);
-
}
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
body = null;
id = null;
@@ -270,8 +259,5 @@
toScope = "page";
type = null;
value = null;
-
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/DefineTei.java Fri Feb 10 13:00:51 2006
@@ -1,63 +1,53 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>define</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>define</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class DefineTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
- String type = (String)data.getAttribute("type");
+ String type = (String) data.getAttribute("type");
Object name = data.getAttribute("name");
Object value = data.getAttribute("value");
+
if (type == null) {
- if ( (value!=null) || (name==null) )
+ if ((value != null) || (name == null)) {
type = "java.lang.String";
- else
+ } else {
type = "java.lang.Object";
+ }
}
return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- type,
- true,
- VariableInfo.AT_END )
+ new VariableInfo(data.getAttributeString("id"), type, true,
+ VariableInfo.AT_END)
};
-
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTag.java Fri Feb 10 13:00:51 2006
@@ -1,49 +1,71 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.taglib.bean;
-import java.util.ArrayList;
-import java.util.Enumeration;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
+import java.util.ArrayList;
+import java.util.Enumeration;
/**
- * Define a scripting variable based on the value(s) of the specified
- * header received with this request.
+ * Define a scripting variable based on the value(s) of the specified header
+ * received with this request.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
public class HeaderTag extends TagSupport {
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * Return an array of header values if <code>multiple</code> is non-null.
+ */
+ protected String multiple = null;
+
+ /**
+ * The name of the header whose value is to be exposed.
+ */
+ protected String name = null;
+
+ /**
+ * The default value to return if no header of the specified name is
+ * found.
+ */
+ protected String value = null;
+
public String getId() {
return (this.id);
}
@@ -52,18 +74,6 @@
this.id = id;
}
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources(
- "org.apache.struts.taglib.bean.LocalStrings");
-
- /**
- * Return an array of header values if <code>multiple</code> is non-null.
- */
- protected String multiple = null;
-
public String getMultiple() {
return (this.multiple);
}
@@ -72,11 +82,6 @@
this.multiple = multiple;
}
- /**
- * The name of the header whose value is to be exposed.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -85,11 +90,6 @@
this.name = name;
}
- /**
- * The default value to return if no header of the specified name is found.
- */
- protected String value = null;
-
public String getValue() {
return (this.value);
}
@@ -103,10 +103,9 @@
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
if (this.multiple == null) {
this.handleSingleHeader();
} else {
@@ -118,39 +117,45 @@
/**
* Expose an array of header values.
+ *
* @throws JspException
* @since Struts 1.2
*/
- protected void handleMultipleHeaders() throws JspException {
+ protected void handleMultipleHeaders()
+ throws JspException {
ArrayList values = new ArrayList();
Enumeration items =
((HttpServletRequest) pageContext.getRequest()).getHeaders(name);
-
- while (items.hasMoreElements()){
+
+ while (items.hasMoreElements()) {
values.add(items.nextElement());
}
-
- if (values.isEmpty() && (this.value != null)){
+
+ if (values.isEmpty() && (this.value != null)) {
values.add(this.value);
}
-
- String headers[] = new String[values.size()];
+
+ String[] headers = new String[values.size()];
+
if (headers.length == 0) {
JspException e =
new JspException(messages.getMessage("header.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
-
+
pageContext.setAttribute(id, values.toArray(headers));
}
/**
* Expose a single header value.
+ *
* @throws JspException
* @since Struts 1.2
*/
- protected void handleSingleHeader() throws JspException {
+ protected void handleSingleHeader()
+ throws JspException {
String value =
((HttpServletRequest) pageContext.getRequest()).getHeader(name);
@@ -161,10 +166,11 @@
if (value == null) {
JspException e =
new JspException(messages.getMessage("header.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
-
+
pageContext.setAttribute(id, value);
}
@@ -172,13 +178,10 @@
* Release all allocated resources.
*/
public void release() {
-
super.release();
id = null;
multiple = null;
name = null;
value = null;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/HeaderTei.java Fri Feb 10 13:00:51 2006
@@ -1,58 +1,49 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>header</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>header</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class HeaderTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
String className = null;
- if (data.getAttribute("multiple") == null)
+
+ if (data.getAttribute("multiple") == null) {
className = "java.lang.String";
- else
+ } else {
className = "java.lang.String[]";
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- className,
- true,
- VariableInfo.AT_BEGIN)
- };
+ }
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), className, true,
+ VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTag.java Fri Feb 10 13:00:51 2006
@@ -1,52 +1,52 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.taglib.bean;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
+import org.apache.struts.util.RequestUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
import java.io.BufferedInputStream;
import java.io.InputStreamReader;
+
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.util.RequestUtils;
-import org.apache.struts.taglib.TagUtils;
/**
- * Define the contents of a specified intra-application request as a
- * page scope attribute of type <code>java.lang.String</code>. If the
- * current request is part of a session, the session identifier will be
- * included in the generated request, so it will be part of the same
- * session.
- * <p>
- * <strong>FIXME</strong>: In a servlet 2.3 environment, we can use a
- * wrapped response passed to RequestDispatcher.include().
+ * Define the contents of a specified intra-application request as a page
+ * scope attribute of type <code>java.lang.String</code>. If the current
+ * request is part of a session, the session identifier will be included in
+ * the generated request, so it will be part of the same session. <p>
+ * <strong>FIXME</strong>: In a servlet 2.3 environment, we can use a wrapped
+ * response passed to RequestDispatcher.include().
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-21 19:08:45 -0400 (Sun, 21 Aug 2005)
+ * $
*/
-
public class IncludeTag extends TagSupport {
-
// ------------------------------------------------------------- Properties
/**
@@ -55,10 +55,45 @@
protected static final int BUFFER_SIZE = 256;
/**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
+
+ /**
* The anchor to be added to the end of the generated hyperlink.
*/
protected String anchor = null;
+ /**
+ * The name of the global <code>ActionForward</code> that contains a path
+ * to our requested resource.
+ */
+ protected String forward = null;
+
+ /**
+ * The absolute URL to the resource to be included.
+ */
+ protected String href = null;
+
+ /**
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
+ */
+ protected String id = null;
+
+ /**
+ * The context-relative URI of the page or servlet to be included.
+ */
+ protected String page = null;
+
+ /**
+ * Include transaction token (if any) in the hyperlink?
+ */
+ protected boolean transaction = false;
+ protected boolean useLocalEncoding = false;
+
public String getAnchor() {
return (this.anchor);
}
@@ -67,12 +102,6 @@
this.anchor = anchor;
}
- /**
- * The name of the global <code>ActionForward</code> that contains a
- * path to our requested resource.
- */
- protected String forward = null;
-
public String getForward() {
return (this.forward);
}
@@ -81,11 +110,6 @@
this.forward = forward;
}
- /**
- * The absolute URL to the resource to be included.
- */
- protected String href = null;
-
public String getHref() {
return (this.href);
}
@@ -94,12 +118,6 @@
this.href = href;
}
- /**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
- */
- protected String id = null;
-
public String getId() {
return (this.id);
}
@@ -108,17 +126,6 @@
this.id = id;
}
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources("org.apache.struts.taglib.bean.LocalStrings");
-
- /**
- * The context-relative URI of the page or servlet to be included.
- */
- protected String page = null;
-
public String getPage() {
return (this.page);
}
@@ -127,11 +134,6 @@
this.page = page;
}
- /**
- * Include transaction token (if any) in the hyperlink?
- */
- protected boolean transaction = false;
-
public boolean getTransaction() {
return (this.transaction);
}
@@ -139,92 +141,101 @@
public void setTransaction(boolean transaction) {
this.transaction = transaction;
}
-
- protected boolean useLocalEncoding = false;
-
- public boolean isUseLocalEncoding() {
- return useLocalEncoding;
- }
-
- public void setUseLocalEncoding(boolean b) {
- useLocalEncoding = b;
- }
+
+ public boolean isUseLocalEncoding() {
+ return useLocalEncoding;
+ }
+
+ public void setUseLocalEncoding(boolean b) {
+ useLocalEncoding = b;
+ }
// --------------------------------------------------------- Public Methods
/**
- * Define the contents returned for the specified resource as a
- * page scope attribute.
+ * Define the contents returned for the specified resource as a page scope
+ * attribute.
*
- * @exception JspException if a JSP error occurs
+ * @throws JspException if a JSP error occurs
*/
public int doStartTag() throws JspException {
-
// Set up a URLConnection to read the requested resource
Map params =
- TagUtils.getInstance().computeParameters(
- pageContext,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- transaction);
+ TagUtils.getInstance().computeParameters(pageContext, null, null,
+ null, null, null, null, null, transaction);
+
// FIXME - <html:link> attributes
String urlString = null;
URL url = null;
+
try {
urlString =
- TagUtils.getInstance().computeURLWithCharEncoding(pageContext, forward, href, page, null,null, params, anchor, false, useLocalEncoding);
+ TagUtils.getInstance().computeURLWithCharEncoding(pageContext,
+ forward, href, page, null, null, params, anchor, false,
+ useLocalEncoding);
+
if (urlString.indexOf(':') < 0) {
- HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
url = new URL(RequestUtils.requestURL(request), urlString);
} else {
url = new URL(urlString);
}
} catch (MalformedURLException e) {
TagUtils.getInstance().saveException(pageContext, e);
- throw new JspException(messages.getMessage("include.url", e.toString()));
+ throw new JspException(messages.getMessage("include.url",
+ e.toString()));
}
URLConnection conn = null;
+
try {
// Set up the basic connection
conn = url.openConnection();
conn.setAllowUserInteraction(false);
conn.setDoInput(true);
conn.setDoOutput(false);
+
// Add a session id cookie if appropriate
- HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
addCookie(conn, urlString, request);
+
// Connect to the requested resource
conn.connect();
} catch (Exception e) {
TagUtils.getInstance().saveException(pageContext, e);
- throw new JspException(
- messages.getMessage("include.open", url.toString(), e.toString()));
+ throw new JspException(messages.getMessage("include.open",
+ url.toString(), e.toString()));
}
// Copy the contents of this URL
StringBuffer sb = new StringBuffer();
+
try {
- BufferedInputStream is = new BufferedInputStream(conn.getInputStream());
+ BufferedInputStream is =
+ new BufferedInputStream(conn.getInputStream());
InputStreamReader in = new InputStreamReader(is); // FIXME - encoding
- char buffer[] = new char[BUFFER_SIZE];
+ char[] buffer = new char[BUFFER_SIZE];
int n = 0;
+
while (true) {
n = in.read(buffer);
- if (n < 1)
+
+ if (n < 1) {
break;
+ }
+
sb.append(buffer, 0, n);
}
+
in.close();
} catch (Exception e) {
TagUtils.getInstance().saveException(pageContext, e);
- throw new JspException(
- messages.getMessage("include.read", url.toString(), e.toString()));
+ throw new JspException(messages.getMessage("include.read",
+ url.toString(), e.toString()));
}
// Define the retrieved content as a page scope attribute
@@ -233,20 +244,24 @@
// Skip any body of this tag
return (SKIP_BODY);
}
+
/**
- * Add a session id cookie if appropriate. Can be overloaded to
- * support a cluster.
+ * Add a session id cookie if appropriate. Can be overloaded to support a
+ * cluster.
+ *
* @param conn
* @param urlString
* @param request
* @since Struts 1.2.0
*/
- protected void addCookie(URLConnection conn, String urlString, HttpServletRequest request) {
+ protected void addCookie(URLConnection conn, String urlString,
+ HttpServletRequest request) {
if ((conn instanceof HttpURLConnection)
&& urlString.startsWith(request.getContextPath())
&& (request.getRequestedSessionId() != null)
&& request.isRequestedSessionIdFromCookie()) {
StringBuffer sb = new StringBuffer("JSESSIONID=");
+
sb.append(request.getRequestedSessionId());
conn.setRequestProperty("Cookie", sb.toString());
}
@@ -263,6 +278,5 @@
id = null;
page = null;
transaction = false;
- }
-
+ }
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/IncludeTei.java Fri Feb 10 13:00:51 2006
@@ -1,53 +1,41 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>include</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>include</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class IncludeTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- "java.lang.String",
- true,
- VariableInfo.AT_BEGIN)
- };
-
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), "java.lang.String",
+ true, VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/MessageTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/MessageTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/MessageTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/MessageTag.java Fri Feb 10 13:00:51 2006
@@ -1,40 +1,47 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2005 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.taglib.bean;
-import java.util.Locale;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TagSupport;
-
import org.apache.struts.Globals;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.util.MessageResources;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import java.util.Locale;
+
/**
* Custom tag that retrieves an internationalized messages string (with
* optional parametric replacement) from the <code>ActionResources</code>
* object stored as a context attribute by our associated
* <code>ActionServlet</code> implementation.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-09-16 09:38:33 -0400 (Fri, 16 Sep 2005)
+ * $
*/
public class MessageTag extends TagSupport {
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
@@ -43,6 +50,56 @@
*/
protected String arg0 = null;
+ /**
+ * The second optional argument.
+ */
+ protected String arg1 = null;
+
+ /**
+ * The third optional argument.
+ */
+ protected String arg2 = null;
+
+ /**
+ * The fourth optional argument.
+ */
+ protected String arg3 = null;
+
+ /**
+ * The fifth optional argument.
+ */
+ protected String arg4 = null;
+
+ /**
+ * The servlet context attribute key for our resources.
+ */
+ protected String bundle = null;
+
+ /**
+ * The message key of the message to be retrieved.
+ */
+ protected String key = null;
+
+ /**
+ * Name of the bean that contains the message key.
+ */
+ protected String name = null;
+
+ /**
+ * Name of the property to be accessed on the specified bean.
+ */
+ protected String property = null;
+
+ /**
+ * The scope to be searched to retrieve the specified bean.
+ */
+ protected String scope = null;
+
+ /**
+ * The session scope key under which our Locale is stored.
+ */
+ protected String localeKey = Globals.LOCALE_KEY;
+
public String getArg0() {
return (this.arg0);
}
@@ -51,11 +108,6 @@
this.arg0 = arg0;
}
- /**
- * The second optional argument.
- */
- protected String arg1 = null;
-
public String getArg1() {
return (this.arg1);
}
@@ -64,11 +116,6 @@
this.arg1 = arg1;
}
- /**
- * The third optional argument.
- */
- protected String arg2 = null;
-
public String getArg2() {
return (this.arg2);
}
@@ -77,11 +124,6 @@
this.arg2 = arg2;
}
- /**
- * The fourth optional argument.
- */
- protected String arg3 = null;
-
public String getArg3() {
return (this.arg3);
}
@@ -90,11 +132,6 @@
this.arg3 = arg3;
}
- /**
- * The fifth optional argument.
- */
- protected String arg4 = null;
-
public String getArg4() {
return (this.arg4);
}
@@ -103,11 +140,6 @@
this.arg4 = arg4;
}
- /**
- * The servlet context attribute key for our resources.
- */
- protected String bundle = null;
-
public String getBundle() {
return (this.bundle);
}
@@ -116,11 +148,6 @@
this.bundle = bundle;
}
- /**
- * The message key of the message to be retrieved.
- */
- protected String key = null;
-
public String getKey() {
return (this.key);
}
@@ -129,11 +156,6 @@
this.key = key;
}
- /**
- * Name of the bean that contains the message key.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -142,11 +164,6 @@
this.name = name;
}
- /**
- * Name of the property to be accessed on the specified bean.
- */
- protected String property = null;
-
public String getProperty() {
return (this.property);
}
@@ -155,11 +172,6 @@
this.property = property;
}
- /**
- * The scope to be searched to retrieve the specified bean.
- */
- protected String scope = null;
-
public String getScope() {
return (this.scope);
}
@@ -168,11 +180,6 @@
this.scope = scope;
}
- /**
- * The session scope key under which our Locale is stored.
- */
- protected String localeKey = Globals.LOCALE_KEY;
-
public String getLocale() {
return (this.localeKey);
}
@@ -181,57 +188,51 @@
this.localeKey = localeKey;
}
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources(
- "org.apache.struts.taglib.bean.LocalStrings");
-
// --------------------------------------------------------- Public Methods
/**
* Process the start tag.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
String key = this.key;
+
if (key == null) {
// Look up the requested property value
- Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
- if (value != null && !(value instanceof String)) {
+ Object value =
+ TagUtils.getInstance().lookup(pageContext, name, property, scope);
+
+ if ((value != null) && !(value instanceof String)) {
JspException e =
new JspException(messages.getMessage("message.property", key));
- TagUtils.getInstance().saveException(pageContext, e);
+
+ TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
+
key = (String) value;
}
// Construct the optional arguments array we will be using
- Object args[] = new Object[] { arg0, arg1, arg2, arg3, arg4 };
+ Object[] args = new Object[] { arg0, arg1, arg2, arg3, arg4 };
// Retrieve the message string we are looking for
String message =
- TagUtils.getInstance().message(
- pageContext,
- this.bundle,
- this.localeKey,
- key,
- args);
-
+ TagUtils.getInstance().message(pageContext, this.bundle,
+ this.localeKey, key, args);
+
if (message == null) {
- Locale locale = TagUtils.getInstance().
- getUserLocale(pageContext, this.localeKey);
- String localeVal = (locale == null) ? "default locale" : locale.toString();
+ Locale locale =
+ TagUtils.getInstance().getUserLocale(pageContext, this.localeKey);
+ String localeVal =
+ (locale == null) ? "default locale" : locale.toString();
JspException e =
- new JspException(
- messages.getMessage(
- "message.message", "\"" + key + "\"",
- "\"" + (bundle == null ? "(default bundle)" : bundle) + "\"",
- localeVal));
+ new JspException(messages.getMessage("message.message",
+ "\"" + key + "\"",
+ "\"" + ((bundle == null) ? "(default bundle)" : bundle)
+ + "\"", localeVal));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
@@ -239,14 +240,12 @@
TagUtils.getInstance().write(pageContext, message);
return (SKIP_BODY);
-
}
/**
* Release any acquired resources.
*/
public void release() {
-
super.release();
arg0 = null;
arg1 = null;
@@ -259,7 +258,5 @@
property = null;
scope = null;
localeKey = Globals.LOCALE_KEY;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTag.java Fri Feb 10 13:00:51 2006
@@ -1,50 +1,56 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
-
/**
- * Define a scripting variable that exposes the requested page context
- * item as a scripting variable and a page scope bean.
+ * Define a scripting variable that exposes the requested page context item as
+ * a scripting variable and a page scope bean.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class PageTag extends TagSupport {
-
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
-
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * The name of the page context property to be retrieved.
+ */
+ protected String property = null;
+
public String getId() {
return (this.id);
}
@@ -53,20 +59,6 @@
this.id = id;
}
-
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
-
- /**
- * The name of the page context property to be retrieved.
- */
- protected String property = null;
-
public String getProperty() {
return (this.property);
}
@@ -75,54 +67,48 @@
this.property = property;
}
-
// --------------------------------------------------------- Public Methods
-
/**
- * Retrieve the required configuration object and expose it as a
- * scripting variable.
+ * Retrieve the required configuration object and expose it as a scripting
+ * variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
// Retrieve the requested object to be exposed
Object object = null;
- if ("application".equalsIgnoreCase(property))
+
+ if ("application".equalsIgnoreCase(property)) {
object = pageContext.getServletContext();
- else if ("config".equalsIgnoreCase(property))
+ } else if ("config".equalsIgnoreCase(property)) {
object = pageContext.getServletConfig();
- else if ("request".equalsIgnoreCase(property))
+ } else if ("request".equalsIgnoreCase(property)) {
object = pageContext.getRequest();
- else if ("response".equalsIgnoreCase(property))
+ } else if ("response".equalsIgnoreCase(property)) {
object = pageContext.getResponse();
- else if ("session".equalsIgnoreCase(property))
+ } else if ("session".equalsIgnoreCase(property)) {
object = pageContext.getSession();
- else {
- JspException e = new JspException
- (messages.getMessage("page.selector", property));
+ } else {
+ JspException e =
+ new JspException(messages.getMessage("page.selector", property));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Expose this value as a scripting variable
pageContext.setAttribute(id, object);
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
-
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
id = null;
property = null;
-
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/PageTei.java Fri Feb 10 13:00:51 2006
@@ -1,68 +1,58 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>page</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>page</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class PageTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
String type = null;
String property = data.getAttributeString("property");
- if ("application".equalsIgnoreCase(property))
+
+ if ("application".equalsIgnoreCase(property)) {
type = "javax.servlet.ServletContext";
- else if ("config".equalsIgnoreCase(property))
+ } else if ("config".equalsIgnoreCase(property)) {
type = "javax.servlet.ServletConfig";
- else if ("request".equalsIgnoreCase(property))
+ } else if ("request".equalsIgnoreCase(property)) {
type = "javax.servlet.ServletRequest";
- else if ("response".equalsIgnoreCase(property))
+ } else if ("response".equalsIgnoreCase(property)) {
type = "javax.servlet.ServletResponse";
- else if ("session".equalsIgnoreCase(property))
+ } else if ("session".equalsIgnoreCase(property)) {
type = "javax.servlet.http.HttpSession";
- else
+ } else {
type = "java.lang.Object";
+ }
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- type,
- true,
- VariableInfo.AT_BEGIN)
- };
-
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), type, true,
+ VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTag.java Fri Feb 10 13:00:51 2006
@@ -1,45 +1,68 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.taglib.bean;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
+
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
-
/**
* Define a scripting variable based on the value(s) of the specified
* parameter received with this request.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
public class ParameterTag extends TagSupport {
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * Return an array of parameter values if <code>multiple</code> is
+ * non-null.
+ */
+ protected String multiple = null;
+
+ /**
+ * The name of the parameter whose value is to be exposed.
+ */
+ protected String name = null;
+
+ /**
+ * The default value to return if no parameter of the specified name is
+ * found.
+ */
+ protected String value = null;
+
public String getId() {
return (this.id);
}
@@ -48,19 +71,6 @@
this.id = id;
}
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources(
- "org.apache.struts.taglib.bean.LocalStrings");
-
- /**
- * Return an array of parameter values if <code>multiple</code> is
- * non-null.
- */
- protected String multiple = null;
-
public String getMultiple() {
return (this.multiple);
}
@@ -69,11 +79,6 @@
this.multiple = multiple;
}
- /**
- * The name of the parameter whose value is to be exposed.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -82,12 +87,6 @@
this.name = name;
}
- /**
- * The default value to return if no parameter of the specified name is
- * found.
- */
- protected String value = null;
-
public String getValue() {
return (this.value);
}
@@ -101,13 +100,13 @@
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
// Deal with a single parameter value
if (multiple == null) {
String value = pageContext.getRequest().getParameter(name);
+
if ((value == null) && (this.value != null)) {
value = this.value;
}
@@ -115,16 +114,19 @@
if (value == null) {
JspException e =
new JspException(messages.getMessage("parameter.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
pageContext.setAttribute(id, value);
+
return (SKIP_BODY);
}
// Deal with multiple parameter values
- String values[] = pageContext.getRequest().getParameterValues(name);
+ String[] values = pageContext.getRequest().getParameterValues(name);
+
if ((values == null) || (values.length == 0)) {
if (this.value != null) {
values = new String[] { this.value };
@@ -134,26 +136,24 @@
if ((values == null) || (values.length == 0)) {
JspException e =
new JspException(messages.getMessage("parameter.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
-
+
pageContext.setAttribute(id, values);
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
id = null;
multiple = null;
name = null;
value = null;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ParameterTei.java Fri Feb 10 13:00:51 2006
@@ -1,58 +1,49 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>parameter</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>parameter</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class ParameterTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
String className = null;
- if (data.getAttribute("multiple") == null)
+
+ if (data.getAttribute("multiple") == null) {
className = "java.lang.String";
- else
+ } else {
className = "java.lang.String[]";
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- className,
- true,
- VariableInfo.AT_BEGIN)
- };
+ }
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), className, true,
+ VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTag.java Fri Feb 10 13:00:51 2006
@@ -1,41 +1,40 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.taglib.bean;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
/**
- * Define a scripting variable based on the contents of the specified
- * web application resource.
+ * Define a scripting variable based on the contents of the specified web
+ * application resource.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
public class ResourceTag extends TagSupport {
-
// ------------------------------------------------------------- Properties
/**
@@ -44,11 +43,29 @@
protected static final int BUFFER_SIZE = 256;
/**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
+
+ /**
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
*/
protected String id = null;
+ /**
+ * Return an InputStream to the specified resource if this is non-null.
+ */
+ protected String input = null;
+
+ /**
+ * The module-relative URI of the resource whose contents are to be
+ * exposed.
+ */
+ protected String name = null;
+
public String getId() {
return (this.id);
}
@@ -57,11 +74,6 @@
this.id = id;
}
- /**
- * Return an InputStream to the specified resource if this is non-null.
- */
- protected String input = null;
-
public String getInput() {
return (this.input);
}
@@ -70,19 +82,6 @@
this.input = input;
}
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources(
- "org.apache.struts.taglib.bean.LocalStrings");
-
- /**
- * The module-relative URI of the resource whose contents are to
- * be exposed.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -96,17 +95,17 @@
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
// Acquire an input stream to the specified resource
InputStream stream =
pageContext.getServletContext().getResourceAsStream(name);
-
+
if (stream == null) {
JspException e =
new JspException(messages.getMessage("resource.get", name));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
@@ -114,6 +113,7 @@
// If we are returning an InputStream, do so and return
if (input != null) {
pageContext.setAttribute(id, stream);
+
return (SKIP_BODY);
}
@@ -121,37 +121,36 @@
try {
StringBuffer sb = new StringBuffer();
InputStreamReader reader = new InputStreamReader(stream);
- char buffer[] = new char[BUFFER_SIZE];
+ char[] buffer = new char[BUFFER_SIZE];
int n = 0;
+
while (true) {
n = reader.read(buffer);
+
if (n < 1) {
break;
}
+
sb.append(buffer, 0, n);
}
+
reader.close();
pageContext.setAttribute(id, sb.toString());
-
} catch (IOException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException(messages.getMessage("resource.get", name));
}
-
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
id = null;
input = null;
name = null;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTei.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTei.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTei.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/ResourceTei.java Fri Feb 10 13:00:51 2006
@@ -1,58 +1,49 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
-
/**
- * Implementation of <code>TagExtraInfo</code> for the <b>resource</b>
- * tag, identifying the scripting object(s) to be made visible.
+ * Implementation of <code>TagExtraInfo</code> for the <b>resource</b> tag,
+ * identifying the scripting object(s) to be made visible.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class ResourceTei extends TagExtraInfo {
-
-
/**
* Return information about the scripting variables to be created.
*/
public VariableInfo[] getVariableInfo(TagData data) {
-
String type = null;
- if (data.getAttribute("input") == null)
+
+ if (data.getAttribute("input") == null) {
type = "java.lang.String";
- else
+ } else {
type = "java.io.InputStream";
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- type,
- true,
- VariableInfo.AT_BEGIN)
- };
+ }
+ return new VariableInfo[] {
+ new VariableInfo(data.getAttributeString("id"), type, true,
+ VariableInfo.AT_BEGIN)
+ };
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTag.java?rev=376840&r1=376839&r2=376840&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/bean/SizeTag.java Fri Feb 10 13:00:51 2006
@@ -1,53 +1,77 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.taglib.bean;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Map;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.taglib.TagUtils;
+import java.lang.reflect.Array;
+
+import java.util.Collection;
+import java.util.Map;
/**
- * Define a scripting variable that will contain the number of elements
- * found in a specified array, Collection, or Map.
+ * Define a scripting variable that will contain the number of elements found
+ * in a specified array, Collection, or Map.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public class SizeTag extends TagSupport {
-
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// ------------------------------------------------------------- Properties
-
/**
* The actual collection to be counted.
*/
protected Object collection = null;
+ /**
+ * The name of the scripting variable that will be exposed as a page scope
+ * attribute.
+ */
+ protected String id = null;
+
+ /**
+ * The name of the bean owning the property to be counted.
+ */
+ protected String name = null;
+
+ /**
+ * The name of the property to be retrieved.
+ */
+ protected String property = null;
+
+ /**
+ * The scope within which to search for the specified bean.
+ */
+ protected String scope = null;
+
public Object getCollection() {
return (this.collection);
}
@@ -56,13 +80,6 @@
this.collection = collection;
}
-
- /**
- * The name of the scripting variable that will be exposed as a page
- * scope attribute.
- */
- protected String id = null;
-
public String getId() {
return (this.id);
}
@@ -71,21 +88,6 @@
this.id = id;
}
-
- /**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
-
-
- /**
- * The name of the bean owning the property to be counted.
- */
- protected String name = null;
-
public String getName() {
return (this.name);
}
@@ -94,12 +96,6 @@
this.name = name;
}
-
- /**
- * The name of the property to be retrieved.
- */
- protected String property = null;
-
public String getProperty() {
return (this.property);
}
@@ -108,12 +104,6 @@
this.property = property;
}
-
- /**
- * The scope within which to search for the specified bean.
- */
- protected String scope = null;
-
public String getScope() {
return (this.scope);
}
@@ -122,37 +112,40 @@
this.scope = scope;
}
-
// --------------------------------------------------------- Public Methods
-
/**
* Retrieve the required property and expose it as a scripting variable.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
// Retrieve the required property value
Object value = this.collection;
+
if (value == null) {
if (name == null) {
// Must specify either a collection attribute or a name
// attribute.
- JspException e = new JspException
- (messages.getMessage("size.noCollectionOrName"));
+ JspException e =
+ new JspException(messages.getMessage(
+ "size.noCollectionOrName"));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
-
- value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
+
+ value =
+ TagUtils.getInstance().lookup(pageContext, name, property, scope);
}
// Identify the number of elements, based on the collection type
int size = 0;
+
if (value == null) {
- JspException e = new JspException
- (messages.getMessage("size.collection"));
+ JspException e =
+ new JspException(messages.getMessage("size.collection"));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
} else if (value.getClass().isArray()) {
@@ -162,33 +155,29 @@
} else if (value instanceof Map) {
size = ((Map) value).size();
} else {
- JspException e = new JspException
- (messages.getMessage("size.collection"));
+ JspException e =
+ new JspException(messages.getMessage("size.collection"));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Expose this size as a scripting variable
pageContext.setAttribute(this.id, new Integer(size),
- PageContext.PAGE_SCOPE);
- return (SKIP_BODY);
+ PageContext.PAGE_SCOPE);
+ return (SKIP_BODY);
}
-
/**
* Release all allocated resources.
*/
public void release() {
-
super.release();
collection = null;
id = null;
name = null;
property = null;
scope = null;
-
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org