jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/jx ExceptionTag.java
Date Tue, 20 Nov 2001 22:05:53 GMT
luehe       01/11/20 14:05:53

  Modified:    jsptl/conf jr.tld jx.tld
               jsptl/examples/web/i18n Message.jsp MessageFormat.jsp
               jsptl/src/org/apache/taglibs/jsptl/extra/i18n Locale.java
               jsptl/src/org/apache/taglibs/jsptl/resources
                        Resources.properties
               jsptl/src/org/apache/taglibs/jsptl/tag/common
                        BundleSupport.java LocaleSupport.java
                        MessageSupport.java
  Added:       jsptl/examples/web/i18n Exception.jsp ThrowException.jsp
               jsptl/src/javax/servlet/jsptl/i18n LocalizableException.java
               jsptl/src/org/apache/taglibs/jsptl/tag/common
                        ExceptionSupport.java
               jsptl/src/org/apache/taglibs/jsptl/tag/jr ExceptionTag.java
               jsptl/src/org/apache/taglibs/jsptl/tag/jx ExceptionTag.java
  Log:
  [i18n] Added <exception> tag
  
  Revision  Changes    Path
  1.7       +24 -0     jakarta-taglibs/jsptl/conf/jr.tld
  
  Index: jr.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/conf/jr.tld,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jr.tld	2001/11/17 00:18:07	1.6
  +++ jr.tld	2001/11/20 22:05:53	1.7
  @@ -291,6 +291,30 @@
     </tag>
   
     <tag>
  +    <name>exception</name>
  +    <tag-class>org.apache.taglibs.jsptl.tag.jr.ExceptionTag</tag-class>
  +    <body-content>EMPTY</body-content>
  +    <description>
  +        Prints the given exception in localized format
  +    </description>
  +    <attribute>
  +        <name>value</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>bundle</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>stackTrace</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
       <name>locale</name>
       <tag-class>org.apache.taglibs.jsptl.tag.jr.LocaleTag</tag-class>
       <tei-class>org.apache.taglibs.jsptl.tei.LocaleTEI</tei-class>
  
  
  
  1.7       +24 -0     jakarta-taglibs/jsptl/conf/jx.tld
  
  Index: jx.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/conf/jx.tld,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jx.tld	2001/11/17 00:18:07	1.6
  +++ jx.tld	2001/11/20 22:05:53	1.7
  @@ -373,6 +373,30 @@
     </tag>
   
     <tag>
  +    <name>exception</name>
  +    <tag-class>org.apache.taglibs.jsptl.tag.jx.ExceptionTag</tag-class>
  +    <body-content>EMPTY</body-content>
  +    <description>
  +        Prints the given exception in localized format
  +    </description>
  +    <attribute>
  +        <name>value</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>bundle</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>stackTrace</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
       <name>locale</name>
       <tag-class>org.apache.taglibs.jsptl.tag.jx.LocaleTag</tag-class>
       <tei-class>org.apache.taglibs.jsptl.tei.LocaleTEI</tei-class>
  
  
  
  1.4       +1 -1      jakarta-taglibs/jsptl/examples/web/i18n/Message.jsp
  
  Index: Message.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/examples/web/i18n/Message.jsp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Message.jsp	2001/11/19 21:21:53	1.3
  +++ Message.jsp	2001/11/20 22:05:53	1.4
  @@ -2,7 +2,7 @@
   
   <html>
   <head>
  -  <title>JSPTL: Formatting Support -- Locale, Bundle, and Message Example</title>
  +  <title>JSPTL: I18N Support -- Locale, Bundle, and Message Example</title>
   </head>
   <body bgcolor="#FFFFFF">
   <h3>I18N Transformations</h3>
  
  
  
  1.2       +1 -1      jakarta-taglibs/jsptl/examples/web/i18n/MessageFormat.jsp
  
  Index: MessageFormat.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/examples/web/i18n/MessageFormat.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MessageFormat.jsp	2001/11/16 00:20:07	1.1
  +++ MessageFormat.jsp	2001/11/20 22:05:53	1.2
  @@ -2,7 +2,7 @@
   
   <html>
   <head>
  -  <title>JSPTL: Formatting Support -- MessageFormat Example</title>
  +  <title>JSPTL: Message Formatting Support -- MessageFormat Example</title>
   </head>
   <body bgcolor="#FFFFFF">
   <h3>Parametric Replacement</h3>
  
  
  
  1.1                  jakarta-taglibs/jsptl/examples/web/i18n/Exception.jsp
  
  Index: Exception.jsp
  ===================================================================
  <%@ taglib prefix="jx" uri="http://java.sun.com/jsptl/ea/jx" %>
  
  <html>
  <head>
    <title>JSPTL: Exception Support -- Exception Example</title>
  </head>
  <body bgcolor="#FFFFFF">
  
  <%@ page isErrorPage="true" %>
  <jx:exception/>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/jsptl/examples/web/i18n/ThrowException.jsp
  
  Index: ThrowException.jsp
  ===================================================================
  <%@ taglib prefix="jx" uri="http://java.sun.com/jsptl/ea/jx" %>
  
  <html>
  <head>
    <title>Throw Exception</title>
  </head>
  <body bgcolor="#FFFFFF">
  
  <%@ page errorPage="Exception.jsp" %>
  <%
  if (true)
      throw new Exception("test");
  %>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/jsptl/src/javax/servlet/jsptl/i18n/LocalizableException.java
  
  Index: LocalizableException.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package javax.servlet.jsptl.i18n;
  
  /**
   * A localizable exception.
   *
   * @author Jan Luehe
   */
  
  public interface LocalizableException {
  
      /**
       * Returns the exception's message key from which the exception's
       * localized message is derived via a resource bundle lookup.
       *
       * @return the exception's message key
       */
      public String getMessageKey();
      
      /**
       * Returns the arguments for parametric replacement on the exception's
       * localized message.
       *
       * @return the exception's message arguments
       */
      public Object[] getMessageArgs();
  }
  
  
  
  1.3       +2 -1      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/extra/i18n/Locale.java
  
  Index: Locale.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/extra/i18n/Locale.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Locale.java	2001/11/17 02:13:29	1.2
  +++ Locale.java	2001/11/20 22:05:53	1.3
  @@ -216,7 +216,8 @@
   	if (basename != null)
   	    bundle = BundleSupport.getBundle(pageContext, basename);
   	else
  -	    bundle = BundleSupport.getDefaultBundle(pageContext);
  +	    bundle = BundleSupport.getDefaultBundle(
  +                pageContext, BundleSupport.DEFAULT_BASENAME);
   
   	if (bundle != null) {
   	    try {
  
  
  
  1.5       +6 -0      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/resources/Resources.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resources.properties	2001/11/19 04:18:06	1.4
  +++ Resources.properties	2001/11/20 22:05:53	1.5
  @@ -97,6 +97,12 @@
   MISSING_RESOURCE_BUNDLE=\
       Resource bundle with base name "{0}" not found
   
  +EXCEPTION_STACKTRACE_BOOLEAN=\
  +    In &lt;exception&gt;, "stacktrace" must be "true" or "false".  Got "{0}" instead.
  +
  +EXCEPTION_NOT_IN_ERROR_PAGE=\
  +    &lt;exception&gt; not in error page
  +
   # XML
   
   PARSE_INVALID_SOURCE=\
  
  
  
  1.5       +24 -21    jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/BundleSupport.java
  
  Index: BundleSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/BundleSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BundleSupport.java	2001/11/19 21:21:53	1.4
  +++ BundleSupport.java	2001/11/20 22:05:53	1.5
  @@ -71,16 +71,23 @@
   public abstract class BundleSupport extends BodyTagSupport {
   
       //*********************************************************************
  -    // Package-scoped constants
  +    // Public constants
   
  -    static final String BASENAME_ATTRIBUTE =
  +    public static final String DEFAULT_BASENAME =
   	"javax.servlet.jsp.jsptl.i18n.basename";
   
   
       //*********************************************************************
  +    // Package-scoped constants
  +
  +    static final String DEFAULT_EXCEPTION_BASENAME =
  +	"javax.servlet.jsp.jsptl.i18n.exception.basename";
  +
  +
  +    //*********************************************************************
       // Private constants
   
  -    private static final String FALLBACK_LOCALE_ATTRIBUTE =
  +    private static final String FALLBACK_LOCALE =
   	"javax.servlet.jsp.jsptl.i18n.fallbackLocale";
   
   
  @@ -167,7 +174,7 @@
   	     * If no 'var' attribute and no body, we store our base name
   	     * in the javax.servlet.jsp.jsptl.i18n.basename scoped attribute
   	     */
  -	    pageContext.setAttribute(BASENAME_ATTRIBUTE, basename, scope);
  +	    pageContext.setAttribute(DEFAULT_BASENAME, basename, scope);
   	}
   
   	return EVAL_PAGE;
  @@ -225,10 +232,10 @@
   		if (ret == null) {
   		    // use fallback locale
   		    String fallback = (String)
  -			pageContext.findAttribute(FALLBACK_LOCALE_ATTRIBUTE);
  +			pageContext.findAttribute(FALLBACK_LOCALE);
   		    if (fallback == null)
   			fallback = pageContext.getServletContext().
  -			    getInitParameter(FALLBACK_LOCALE_ATTRIBUTE);
  +			    getInitParameter(FALLBACK_LOCALE);
   		    if (fallback != null) {
   			loc = LocaleSupport.parseLocale(fallback, null);
   			ret = ResourceBundle.getBundle(basename, loc);
  @@ -247,29 +254,25 @@
       }
   
       /**
  -     * Gets the resource bundle with the default base name.
  +     * Gets the resource bundle whose base name is determined from the scoped
  +     * attribute or initialization parameter with the given name.
        *
  -     * <p> The default base name is defined by the
  -     * <tt>javax.servlet.jsp.jsptl.i18n.basename</tt> scoped attribute.
  -     *
  -     * @param pageContext the page in which the resource bundle with the
  -     * default base name is requested
  +     * @param pageContext the page in which the resource bundle is requested
  +     * @name the name of the scoped attribute or initialization parameter
        *
  -     * @return the resource bundle with the default base name, or <tt>null</tt>
  -     * if the <tt>javax.servlet.jsp.jsptl.i18n.basename</tt> attribute is not
  -     * defined in any of the scopes, or no resource bundle with the default
  -     * base name exists
  +     * @return the requested resource bundle, or <tt>null</tt>
  +     * if the scoped attribute or initialization parameter with the given name
  +     * does not exist, or the requested resource bundle does not exist
        */
  -    public static ResourceBundle getDefaultBundle(PageContext pageContext) {
  +    public static ResourceBundle getDefaultBundle(PageContext pageContext,
  +						  String name) {
   	
   	ResourceBundle ret = null;
   
  -	String defaultBasename = (String)
  -	    pageContext.findAttribute(BASENAME_ATTRIBUTE);
  +	String defaultBasename = (String) pageContext.findAttribute(name);
   	if (defaultBasename == null)
   	    defaultBasename =
  -		pageContext.getServletContext().getInitParameter(
  -                    BASENAME_ATTRIBUTE);
  +		pageContext.getServletContext().getInitParameter(name);
   	if (defaultBasename != null)
   	    ret = getBundle(pageContext, defaultBasename);
   
  
  
  
  1.3       +2 -2      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/LocaleSupport.java
  
  Index: LocaleSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/LocaleSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocaleSupport.java	2001/11/17 00:18:07	1.2
  +++ LocaleSupport.java	2001/11/20 22:05:53	1.3
  @@ -178,8 +178,8 @@
   		BundleSupport parent = (BundleSupport) t;
   		ret = parent.getBundle().getLocale();
   	    } else {
  -		ResourceBundle bundle =
  -		    BundleSupport.getDefaultBundle(pageContext);
  +		ResourceBundle bundle = BundleSupport.getDefaultBundle(
  +                    pageContext, BundleSupport.DEFAULT_BASENAME);
   		if (bundle != null) {
   		    ret = bundle.getLocale();
   		} else {
  
  
  
  1.5       +2 -1      jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/MessageSupport.java
  
  Index: MessageSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/MessageSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MessageSupport.java	2001/11/19 21:21:53	1.4
  +++ MessageSupport.java	2001/11/20 22:05:53	1.5
  @@ -149,7 +149,8 @@
   		bundle = parent.getBundle();
   		prefix = parent.getPrefix();
   	    } else {
  -		bundle = BundleSupport.getDefaultBundle(pageContext);
  +		bundle = BundleSupport.getDefaultBundle(
  +                    pageContext, BundleSupport.DEFAULT_BASENAME);
   	    }
   	}
   
  
  
  
  1.1                  jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/common/ExceptionSupport.java
  
  Index: ExceptionSupport.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.jsptl.tag.common;
  
  import java.util.*;
  import java.text.*;
  import java.io.*;
  import javax.servlet.ServletContext;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import javax.servlet.jsptl.i18n.LocalizableException;
  import org.apache.taglibs.jsptl.resources.Resources;
  
  /**
   * Support for tag handlers for &lt;exception&gt;, the exception formatting tag
   * in JSPTL 1.0.
   *
   * @author Jan Luehe
   */
  
  public abstract class ExceptionSupport extends TagSupport {
  
      //*********************************************************************
      // Protected state
  
      protected Exception value;                       // 'value' attribute
      protected ResourceBundle bundle;                 // 'bundle' attribute
      protected boolean stackTrace;		     // 'stackTrace' attribute
  
  
      //*********************************************************************
      // Constructor and initialization
  
      public ExceptionSupport() {
  	super();
  	init();
      }
  
      private void init() {
  	value = null;
  	bundle = null;
  	stackTrace = false;
      }
  
  
      //*********************************************************************
      // Tag logic
  
      public int doStartTag() throws JspException {
  	Object[] messageArgs = null;
  
  	if (value == null) {
  	    value = pageContext.getException();
  	    if (value == null)
  		throw new JspTagException(
  		    Resources.getMessage("EXCEPTION_NOT_IN_ERROR_PAGE"));
  	}
  
  	if (bundle == null) {
  	    Tag t = findAncestorWithClass(this, BundleSupport.class);
  	    if (t != null) {
  		// use resource bundle from parent <bundle> tag
  		BundleSupport parent = (BundleSupport) t;
  		bundle = parent.getBundle();
  	    } else {
  		bundle = BundleSupport.getDefaultBundle(
                      pageContext, BundleSupport.DEFAULT_EXCEPTION_BASENAME);
  	    }
  	}
  
  	String key = value.getClass().getName();
  	if (value instanceof LocalizableException) {
  	    LocalizableException le = (LocalizableException) value;
  	    if (le.getMessageKey() != null)
  		key = le.getMessageKey();
  	    messageArgs = le.getMessageArgs();
  	}
  
  	String message = value.getLocalizedMessage();
  	if (bundle != null) {
  	    try {
  		message = bundle.getString(key);
  		if (messageArgs != null) {
  		    MessageFormat formatter = new MessageFormat("");
  		    formatter.setLocale(bundle.getLocale());
  		    formatter.applyPattern(message);
  		    message = formatter.format(messageArgs);
  		}
  	    } catch (MissingResourceException mre) {
  	    }
  	}
  
  	try {
  	    pageContext.getOut().print(message);
  	    if (stackTrace)
  		value.printStackTrace(new PrintWriter(pageContext.getOut()));
  	} catch (IOException ioe) {
  	    throw new JspTagException(ioe.getMessage());
  	}
  
  	return SKIP_BODY;
      }
  	
      // Releases any resources we may have (or inherit)
      public void release() {
  	init();
      }
  }
  
  
  
  1.1                  jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/jr/ExceptionTag.java
  
  Index: ExceptionTag.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.jsptl.tag.jr;
  
  import java.util.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.jsptl.tag.common.*;
  
  /**
   * <p>A handler for &lt;exception&gt; that supports rtexprvalue-based
   * attributes.</p>
   *
   * @author Jan Luehe
   */
  
  public class ExceptionTag extends ExceptionSupport {
  
      //*********************************************************************
      // Accessor methods
  
      // for tag attribute
      public void setValue(JspException value) throws JspTagException {
          this.value = value;
      }
  
      // for tag attribute
      public void setBundle(ResourceBundle bundle) throws JspTagException {
          this.bundle = bundle;
      }
  
      // for tag attribute
      public void setStackTrace(boolean stackTrace) throws JspTagException {
          this.stackTrace = stackTrace;
      }
  }
  
  
  
  1.1                  jakarta-taglibs/jsptl/src/org/apache/taglibs/jsptl/tag/jx/ExceptionTag.java
  
  Index: ExceptionTag.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.jsptl.tag.jx;
  
  import java.util.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.jsptl.tag.common.*;
  import org.apache.taglibs.jsptl.resources.Resources;
  
  /**
   * <p>A handler for &lt;exception&gt; that accepts attributes as Strings
   * and evaluates them as expressions at runtime.</p>
   *
   * @author Jan Luehe
   */
  
  public class ExceptionTag extends ExceptionSupport {
  
      //*********************************************************************
      // 'Private' state (implementation details)
  
      private String value_;                       // stores EL-based property
      private String bundle_;		         // stores EL-based property
      private String stackTrace_;		         // stores EL-based property
  
  
      //*********************************************************************
      // Constructor
  
      /**
       * Constructs a new ExceptionTag.  As with TagSupport, subclasses
       * should not provide other constructors and are expected to call
       * the superclass constructor
       */
      public ExceptionTag() {
          super();
          init();
      }
  
  
      //*********************************************************************
      // Tag logic
  
      // evaluates expression and chains to parent
      public int doStartTag() throws JspException {
  
          // evaluate any expressions we were passed, once per invocation
          evaluateExpressions();
  
  	// chain to the parent implementation
  	return super.doStartTag();
      }
  
      // Releases any resources we may have (or inherit)
      public void release() {
          super.release();
          init();
      }
  
  
      //*********************************************************************
      // Accessor methods
  
      // for EL-based attribute
      public void setValue(String value_) {
          this.value_ = value_;
      }
  
      // for EL-based attribute
      public void setBundle(String bundle_) {
          this.bundle_ = bundle_;
      }
  
      // for EL-based attribute
      public void setStackTrace(String stackTrace_) {
          this.stackTrace_ = stackTrace_;
      }
  
  
      //*********************************************************************
      // Private (utility) methods
  
      // (re)initializes state (during release() or construction)
      private void init() {
          // null implies "no expression"
  	value_ = bundle_ = stackTrace_ = null;
      }
  
      // Evaluates expressions as necessary
      private void evaluateExpressions() throws JspException {
          /* 
           * Note: we don't check for type mismatches here; we assume
           * the expression evaluator will return the expected type
           * (by virtue of knowledge we give it about what that type is).
           * A ClassCastException here is truly unexpected, so we let it
           * propagate up.
           */
  
  	value = (Exception) ExpressionUtil.evalNotNull(
  	    "exception", "value", value_, Object.class, this, pageContext);
  	bundle = (ResourceBundle) ExpressionUtil.evalNotNull(
  	    "exception", "bundle", bundle_, String.class, this,
  	    pageContext);
  
  	if (stackTrace_ != null) {
  	    if (stackTrace_.equalsIgnoreCase("false"))
  	        stackTrace = false;
  	    else if (stackTrace_.equalsIgnoreCase("true"))
  		stackTrace = true;
  	    else
  		throw new JspTagException(
  		    Resources.getMessage("PARAM_STACKTRACE_BOOLEAN",
  					 stackTrace_));
  	}
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message