You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/10/30 04:20:29 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/logic CompareTagBase.java ConditionalTagBase.java ForwardTag.java IterateTag.java MatchTag.java PresentTag.java RedirectTag.java
craigmcc 00/10/29 19:20:29
Modified: src/share/org/apache/struts/taglib/logic CompareTagBase.java
ConditionalTagBase.java ForwardTag.java
IterateTag.java MatchTag.java PresentTag.java
RedirectTag.java
Log:
Bring the struts-logic tags up to date with respect to:
* Final protocol for resource release in JSP 1.2 PFD.
* Always storing a JspException as a request attribute.
Revision Changes Path
1.3 +25 -13 jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java
Index: CompareTagBase.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CompareTagBase.java 2000/10/12 23:00:31 1.2
+++ CompareTagBase.java 2000/10/30 03:20:27 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v 1.2 2000/10/12 23:00:31 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:31 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v 1.3 2000/10/30 03:20:27 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:27 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* define values for desired1 and desired2.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:31 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:27 $
*/
public abstract class CompareTagBase extends ConditionalTagBase {
@@ -127,11 +127,11 @@
/**
- * Reset custom attributes to their default state.
+ * Release all allocated resources.
*/
- public void releaseCustomAttributes() {
+ public void release() {
- super.releaseCustomAttributes();
+ super.release();
value = null;
}
@@ -210,9 +210,13 @@
} else if (name != null) {
Object bean = BeanUtils.lookup(pageContext, name, null);
if (property != null) {
- if (bean == null)
- throw new JspException
+ if (bean == null) {
+ JspException e =new JspException
(messages.getMessage("logic.bean", name));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
try {
variable = PropertyUtils.getProperty(bean, property);
} catch (InvocationTargetException e) {
@@ -237,12 +241,20 @@
} else if (parameter != null) {
variable =
pageContext.getRequest().getParameter(parameter);
- } else
- throw new JspException
+ } else {
+ JspException e = new JspException
(messages.getMessage("logic.selector"));
- if (variable == null)
- throw new JspException
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
+ if (variable == null) {
+ JspException e = new JspException
(messages.getMessage("logic.variable", value));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
// Perform the appropriate comparison
int result = 0;
1.2 +7 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java
Index: ConditionalTagBase.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConditionalTagBase.java 2000/09/07 01:35:35 1.1
+++ ConditionalTagBase.java 2000/10/30 03:20:27 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v 1.1 2000/09/07 01:35:35 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2000/09/07 01:35:35 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v 1.2 2000/10/30 03:20:27 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/10/30 03:20:27 $
*
* ====================================================================
*
@@ -72,7 +72,7 @@
* Abstract base class for the various conditional evaluation tags.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/09/07 01:35:35 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/30 03:20:27 $
*/
public abstract class ConditionalTagBase extends TagSupport {
@@ -193,10 +193,11 @@
/**
- * Reset custom attributes to their default state.
+ * Release all allocated resources.
*/
- public void releaseCustomAttributes() {
+ public void release() {
+ super.release();
cookie = null;
header = null;
name = null;
1.3 +13 -8 jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java
Index: ForwardTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ForwardTag.java 2000/10/12 23:00:32 1.2
+++ ForwardTag.java 2000/10/30 03:20:28 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v 1.2 2000/10/12 23:00:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v 1.3 2000/10/30 03:20:28 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:28 $
*
* ====================================================================
*
@@ -80,7 +80,7 @@
* ActionForwards collection associated with our application.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:28 $
*/
public final class ForwardTag extends TagSupport {
@@ -142,9 +142,13 @@
(Action.FORWARDS_KEY, PageContext.APPLICATION_SCOPE);
if (forwards != null)
forward = forwards.findForward(name);
- if (forward == null)
- throw new JspException
+ if (forward == null) {
+ JspException e = new JspException
(messages.getMessage("forward.lookup", name));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
// Forward or redirect to the corresponding actual path
String path = forward.getPath();
@@ -179,10 +183,11 @@
/**
- * Reset custom attributes to their default state.
+ * Release all allocated resources.
*/
- public void releaseCustomAttributes() {
+ public void release() {
+ super.release();
name = null;
}
1.3 +24 -19 jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java
Index: IterateTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IterateTag.java 2000/10/12 23:00:32 1.2
+++ IterateTag.java 2000/10/30 03:20:28 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v 1.2 2000/10/12 23:00:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v 1.3 2000/10/30 03:20:28 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:28 $
*
* ====================================================================
*
@@ -88,7 +88,7 @@
* <b>NOTE</b> - This tag requires a Java2 (JDK 1.2 or later) platform.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:28 $
*/
public final class IterateTag extends BodyTagSupport {
@@ -248,18 +248,26 @@
if (collection == null) {
try {
Object bean = pageContext.findAttribute(name);
- if (bean == null)
- throw new JspException
+ if (bean == null) {
+ JspException e = new JspException
(messages.getMessage("iterate.bean", name));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
if (property == null)
collection = bean;
else
collection =
PropertyUtils.getProperty(bean, property);
- if (collection == null)
- throw new JspException
+ if (collection == null) {
+ JspException e = new JspException
(messages.getMessage("iterate.property",
name, property));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
} catch (IllegalAccessException e) {
pageContext.setAttribute(Action.EXCEPTION_KEY, e,
PageContext.REQUEST_SCOPE);
@@ -291,9 +299,13 @@
iterator = (Iterator) collection;
else if (collection instanceof Map)
iterator = ((Map) collection).entrySet().iterator();
- else
- throw new JspException
+ else {
+ JspException e = new JspException
(messages.getMessage("iterate.iterator", name, property));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
// Calculate the starting offset
if (offset == null)
@@ -401,23 +413,16 @@
/**
- * Release any acquired resources.
+ * Release all allocated resources.
*/
public void release() {
super.release();
+
iterator = null;
lengthCount = 0;
lengthValue = 0;
offsetValue = 0;
-
- }
-
-
- /**
- * Reset custom attributes to their default state.
- */
- public void releaseCustomAttributes() {
id = null;
collection = null;
1.3 +25 -12 jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java
Index: MatchTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MatchTag.java 2000/10/12 23:00:32 1.2
+++ MatchTag.java 2000/10/30 03:20:28 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v 1.2 2000/10/12 23:00:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v 1.3 2000/10/30 03:20:28 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:28 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* is a substring of the specified variable.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:28 $
*/
public class MatchTag extends ConditionalTagBase {
@@ -121,11 +121,11 @@
/**
- * Reset custom attributes to their default state.
+ * Release all allocated resources.
*/
- public void releaseCustomAttributes() {
+ public void release() {
- super.releaseCustomAttributes();
+ super.release();
location = null;
value = null;
@@ -182,9 +182,13 @@
getHeader(header);
} else if (name != null) {
Object bean = BeanUtils.lookup(pageContext, name, null);
- if (bean == null)
- throw new JspException
+ if (bean == null) {
+ JspException e = new JspException
(messages.getMessage("logic.bean", name));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
if (property != null) {
Object propertyValue = null;
try {
@@ -213,12 +217,18 @@
} else if (parameter != null) {
variable = pageContext.getRequest().getParameter(parameter);
} else {
- throw new JspException
+ JspException e = new JspException
(messages.getMessage("logic.selector"));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
}
if (variable == null) {
- throw new JspException
+ JspException e = new JspException
(messages.getMessage("logic.variable", value));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
}
// Perform the comparison requested by the location attribute
@@ -230,8 +240,11 @@
} else if (location.equals("end")) {
matched = variable.endsWith(value);
} else {
- throw new JspException
+ JspException e = new JspException
(messages.getMessage("logic.location", location));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
}
// Return the final result
1.3 +16 -8 jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java
Index: PresentTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PresentTag.java 2000/10/12 23:00:32 1.2
+++ PresentTag.java 2000/10/30 03:20:28 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 1.2 2000/10/12 23:00:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 1.3 2000/10/30 03:20:28 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:28 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* is present for this request.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:28 $
*/
public class PresentTag extends ConditionalTagBase {
@@ -136,9 +136,13 @@
} else if (name != null) {
Object bean = BeanUtils.lookup(pageContext, name, null);
if (property != null) {
- if (bean == null)
- throw new JspException
+ if (bean == null) {
+ JspException e = new JspException
(messages.getMessage("logic.bean", name));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
Object value = null;
try {
value = PropertyUtils.getProperty(bean, property);
@@ -166,9 +170,13 @@
String value =
pageContext.getRequest().getParameter(parameter);
present = (value != null);
- } else
- throw new JspException
+ } else {
+ JspException e = new JspException
(messages.getMessage("logic.selector"));
+ pageContext.setAttribute(Action.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
+ throw e;
+ }
return (present == desired);
1.3 +7 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java
Index: RedirectTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RedirectTag.java 2000/10/12 23:00:32 1.2
+++ RedirectTag.java 2000/10/30 03:20:28 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v 1.2 2000/10/12 23:00:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/12 23:00:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v 1.3 2000/10/30 03:20:28 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/10/30 03:20:28 $
*
* ====================================================================
*
@@ -79,7 +79,7 @@
* the remainder of the current page.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/12 23:00:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/10/30 03:20:28 $
*/
public final class RedirectTag extends TagSupport {
@@ -152,10 +152,11 @@
/**
- * Reset custom attributes to their default state.
+ * Release all allocated resources.
*/
- public void releaseCustomAttributes() {
+ public void release() {
+ super.release();
href = null;
}