Revision: 400
http://svn.sourceforge.net/stripes/?rev=400&view=rev
Author: tfenne
Date: 2006-09-02 06:11:19 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
Merge and slight modification of r399 on the trunk that solves the tag stack
synchronization problems when exceptions occur in the body of tags.
Modified Paths:
--------------
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/FormTag.java
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
Modified: branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/FormTag.java
===================================================================
--- branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/FormTag.java
2006-09-02 12:54:13 UTC (rev 399)
+++ branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/FormTag.java
2006-09-02 13:11:19 UTC (rev 400)
@@ -30,6 +30,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTag;
+import javax.servlet.jsp.tagext.TryCatchFinally;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
@@ -44,7 +45,7 @@
*
* @author Tim Fennell
*/
-public class FormTag extends HtmlTagSupport implements BodyTag {
+public class FormTag extends HtmlTagSupport implements BodyTag,
TryCatchFinally {
/** Log used to log error and debugging information for this class. */
private static Log log = Log.getInstance(FormTag.class);
@@ -227,14 +228,25 @@
catch (IOException ioe) {
throw new StripesJspException("IOException in
FormTag.doEndTag().", ioe);
}
- finally {
- getTagStack().pop();
- }
return EVAL_PAGE;
}
+ /** Rethrows the passed in throwable in all cases. */
+ public void doCatch(Throwable throwable) throws Throwable { throw
throwable; }
+
/**
+ * Used to ensure that the form is always removed from the tag stack so
that there is
+ * never any confusion about tag-parent hierarchies.
+ */
+ public void doFinally() {
+ try { getTagStack().pop(); }
+ catch (Throwable t) {
+ /* Supress anything, because otherwise this might mask any causal
exception. */
+ }
+ }
+
+ /**
* <p>In general writes out a hidden field notifying the server exactly
what fields were
* present on the page. Exact behaviour depends upon whether or not the
current form
* is a wizard or not. When the current form is <b>not</b> a wizard this
method examines
Modified:
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
===================================================================
---
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
2006-09-02 12:54:13 UTC (rev 399)
+++
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
2006-09-02 13:11:19 UTC (rev 400)
@@ -157,10 +157,24 @@
tag.setLabel(label.toString());
tag.setValue(value);
- tag.doStartTag();
- tag.doInitBody();
- tag.doAfterBody();
- tag.doEndTag();
+ try {
+ tag.doStartTag();
+ tag.doInitBody();
+ tag.doAfterBody();
+ tag.doEndTag();
+ }
+ catch (Throwable t) {
+ /** Catch whatever comes back out of the doCatch()
method and deal with it */
+ try { tag.doCatch(t); }
+ catch (Throwable t2) {
+ if (t2 instanceof JspException) throw
(JspException) t2;
+ if (t2 instanceof RuntimeException) throw
(RuntimeException) t2;
+ else throw new StripesJspException(t2);
+ }
+ }
+ finally {
+ tag.doFinally();
+ }
}
}
catch (ExpressionException ee) {
Modified:
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
===================================================================
---
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
2006-09-02 12:54:13 UTC (rev 399)
+++
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
2006-09-02 13:11:19 UTC (rev 400)
@@ -150,10 +150,24 @@
tag.setLabel(label.toString());
tag.setValue(value);
- tag.doStartTag();
- tag.doInitBody();
- tag.doAfterBody();
- tag.doEndTag();
+ try {
+ tag.doStartTag();
+ tag.doInitBody();
+ tag.doAfterBody();
+ tag.doEndTag();
+ }
+ catch (Throwable t) {
+ /** Catch whatever comes back out of the doCatch()
method and deal with it */
+ try { tag.doCatch(t); }
+ catch (Throwable t2) {
+ if (t2 instanceof JspException) throw
(JspException) t2;
+ if (t2 instanceof RuntimeException) throw
(RuntimeException) t2;
+ else throw new StripesJspException(t2);
+ }
+ }
+ finally {
+ tag.doFinally();
+ }
}
}
catch (ExpressionException ee) {
Modified:
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
===================================================================
--- branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-09-02 12:54:13 UTC (rev 399)
+++ branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-09-02 13:11:19 UTC (rev 400)
@@ -26,6 +26,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.TryCatchFinally;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
@@ -40,7 +41,7 @@
*
* @author Tim Fennell
*/
-public abstract class InputTagSupport extends HtmlTagSupport {
+public abstract class InputTagSupport extends HtmlTagSupport implements
TryCatchFinally {
private String formatType;
private String formatPattern;
private boolean focus;
@@ -337,27 +338,36 @@
* @return int the value returned by the child class from doStartInputTag()
*/
public final int doEndTag() throws JspException {
- try {
- int result = doEndInputTag();
+ int result = doEndInputTag();
- if (getFieldErrors() != null) {
- this.errorRenderer.doAfterEndTag();
- }
+ if (getFieldErrors() != null) {
+ this.errorRenderer.doAfterEndTag();
+ }
- if (this.focus) {
- makeFocused();
- }
+ if (this.focus) {
+ makeFocused();
+ }
- this.errorRenderer = null;
- this.fieldErrors = null;
- this.fieldErrorsLoaded = false;
- this.focus = false;
+ this.errorRenderer = null;
+ this.fieldErrors = null;
+ this.fieldErrorsLoaded = false;
+ this.focus = false;
- return result;
+ return result;
+ }
+
+ /** Rethrows the passed in throwable in all cases. */
+ public void doCatch(Throwable throwable) throws Throwable { throw
throwable; }
+
+ /**
+ * Used to ensure that the input tag is always removed from the tag stack
so that there is
+ * never any confusion about tag-parent hierarchies.
+ */
+ public void doFinally() {
+ try { getTagStack().pop(); }
+ catch (Throwable t) {
+ /* Supress anything, because otherwise this might mask any causal
exception. */
}
- finally {
- getTagStack().pop();
- }
}
/**
Modified:
branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
===================================================================
--- branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
2006-09-02 12:54:13 UTC (rev 399)
+++ branches/1.4.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
2006-09-02 13:11:19 UTC (rev 400)
@@ -16,6 +16,7 @@
import net.sourceforge.stripes.controller.StripesConstants;
import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.exception.StripesJspException;
import javax.servlet.jsp.JspException;
import java.util.Set;
@@ -95,9 +96,23 @@
if ( !excludes.contains(name) ) {
hidden.setName(name);
- hidden.doStartTag();
- hidden.doAfterBody();
- hidden.doEndTag();
+ try {
+ hidden.doStartTag();
+ hidden.doAfterBody();
+ hidden.doEndTag();
+ }
+ catch (Throwable t) {
+ /** Catch whatever comes back out of the doCatch()
method and deal with it */
+ try { hidden.doCatch(t); }
+ catch (Throwable t2) {
+ if (t2 instanceof JspException) throw
(JspException) t2;
+ if (t2 instanceof RuntimeException) throw
(RuntimeException) t2;
+ else throw new StripesJspException(t2);
+ }
+ }
+ finally {
+ hidden.doFinally();
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development