henning     2003/02/28 07:39:05

  Modified:    src/java/org/apache/turbine/modules/screens
                        JspErrorScreen.java TemplateScreen.java
                        VelocityDirectScreen.java VelocityErrorScreen.java
                        VelocityScreen.java
               src/java/org/apache/turbine/modules/screens/error
                        InvalidState.java
  Log:
  - Removed TurbineResources references
  - Style fixes
  - comment cleanups
  - reworked some logic in the Error Screens
  - used constants all over the place
  
  Revision  Changes    Path
  1.4       +12 -8     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/JspErrorScreen.java
  
  Index: JspErrorScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/JspErrorScreen.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JspErrorScreen.java       12 Feb 2003 17:52:19 -0000      1.3
  +++ JspErrorScreen.java       28 Feb 2003 15:39:05 -0000      1.4
  @@ -54,28 +54,32 @@
    * <http://www.apache.org/>.
    */
   
  -// Turbine
  +import org.apache.turbine.Turbine;
  +import org.apache.turbine.TurbineConstants;
   
  -import org.apache.turbine.services.resources.TurbineResources;
   import org.apache.turbine.util.RunData;
   
   /**
    * Directs errors at the Jsp error template defined in template.error.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Ingo Schuster</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class JspErrorScreen extends BaseJspScreen
  +public class JspErrorScreen
  +    extends BaseJspScreen
   {
       /**
        * @param data Turbine information.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception a generic exception.
        */
       protected void doBuildTemplate(RunData data)
  -            throws Exception
  +        throws Exception
       {
  -        String errorTemplate = TurbineResources.getString("template.error",
  -                "/error.jsp");
  +        String errorTemplate = Turbine.getConfiguration()
  +            .getString(TurbineConstants.TEMPLATE_ERROR_KEY,
  +                       TurbineConstants.TEMPLATE_ERROR_JSP);
  +        
           setTemplate(data, errorTemplate);
       }
   }
  
  
  
  1.3       +17 -7     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/TemplateScreen.java
  
  Index: TemplateScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/TemplateScreen.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TemplateScreen.java       12 Feb 2003 17:52:19 -0000      1.2
  +++ TemplateScreen.java       28 Feb 2003 15:39:05 -0000      1.3
  @@ -54,12 +54,16 @@
    * <http://www.apache.org/>.
    */
   
  -// Turbine/ECS Imports
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   import org.apache.ecs.ConcreteElement;
  +
   import org.apache.turbine.modules.Screen;
   import org.apache.turbine.modules.ScreenLoader;
  +
   import org.apache.turbine.services.template.TurbineTemplate;
  +
   import org.apache.turbine.util.RunData;
   
   /**
  @@ -75,16 +79,21 @@
    * going on there (it is quite simple really).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public abstract class TemplateScreen extends Screen
  +public abstract class TemplateScreen
  +    extends Screen
   {
  +    /** Logging */
  +    private static Log log = LogFactory.getLog(TemplateScreen.class);
  +
       /**
        * This method should be overidden by subclasses that wish to add
        * specific business logic.
        *
        * @param data Turbine information.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception A generic exception.
        */
       protected abstract void doBuildTemplate(RunData data)
               throws Exception;
  @@ -96,7 +105,7 @@
        *
        * @param data Turbine information.
        * @return A ConcreteElement.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception A generic exception.
        */
       public abstract ConcreteElement buildTemplate(RunData data)
               throws Exception;
  @@ -117,7 +126,7 @@
        *
        * @param data Turbine information.
        * @return A ConcreteElement.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception A generic exception.
        */
       protected ConcreteElement doBuild(RunData data)
               throws Exception
  @@ -182,11 +191,12 @@
        * @param data Turbine information.
        * @param screen Name of screen to redirect to.
        * @param template Name of template.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception A generic exception.
        */
       public void doRedirect(RunData data, String screen, String template)
               throws Exception
       {
  +        log.debug("doRedirect(data, " + screen + ", " + template + ")");
           setTemplate(data, template);
           ScreenLoader.getInstance().exec(data, screen);
       }
  @@ -207,7 +217,7 @@
        *
        * @param data Turbine information.
        * @param template Name of template.
  -     * @exception Exception, a generic exception.
  +     * @exception Exception A generic exception.
        */
       public void doRedirect(RunData data, String template)
               throws Exception
  
  
  
  1.6       +24 -9     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityDirectScreen.java
  
  Index: VelocityDirectScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityDirectScreen.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VelocityDirectScreen.java 12 Feb 2003 17:52:19 -0000      1.5
  +++ VelocityDirectScreen.java 28 Feb 2003 15:39:05 -0000      1.6
  @@ -54,13 +54,22 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.lang.StringUtils;
  +
   import org.apache.commons.lang.exception.ExceptionUtils;
  +
   import org.apache.ecs.ConcreteElement;
   import org.apache.ecs.StringElement;
  -import org.apache.turbine.services.resources.TurbineResources;
  +
  +import org.apache.turbine.Turbine;
  +import org.apache.turbine.TurbineConstants;
  +
   import org.apache.turbine.services.template.TurbineTemplate;
  +
   import org.apache.turbine.services.velocity.TurbineVelocity;
  +
   import org.apache.turbine.util.RunData;
  +
   import org.apache.velocity.context.Context;
   
   /**
  @@ -74,9 +83,11 @@
    * class and override the doBuildTemplate() method.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class VelocityDirectScreen extends VelocityScreen
  +public class VelocityDirectScreen
  +    extends VelocityScreen
   {
   
       /**
  @@ -86,7 +97,8 @@
        * @return A ConcreteElement.
        * @exception Exception, a generic exception.
        */
  -    public ConcreteElement buildTemplate(RunData data) throws Exception
  +    public ConcreteElement buildTemplate(RunData data)
  +        throws Exception
       {
           StringElement output = new StringElement();
           String screenData = null;
  @@ -126,12 +138,15 @@
               // If there is an error, build a $processingException and
               // attempt to call the error.vm template in the screens
               // directory.
  -            context.put("processingException", e.toString());
  -            context.put("stackTrace", ExceptionUtils.getStackTrace(e));
  -            templateName = TurbineResources.getString(
  -                    "template.error", "/error.vm");
  +            context.put ("processingException", e.toString());
  +            context.put ("stackTrace", ExceptionUtils.getStackTrace(e));
  +            
  +            templateName = Turbine.getConfiguration()
  +                .getString(TurbineConstants.TEMPLATE_ERROR_KEY,
  +                           TurbineConstants.TEMPLATE_ERROR_VM);
  +
               if ((templateName.length() > 0) &&
  -                    (templateName.charAt(0) != '/'))
  +                (templateName.charAt(0) != '/'))
               {
                   templateName = '/' + templateName;
               }
  
  
  
  1.6       +12 -5     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityErrorScreen.java
  
  Index: VelocityErrorScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityErrorScreen.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VelocityErrorScreen.java  27 Feb 2003 23:07:42 -0000      1.5
  +++ VelocityErrorScreen.java  28 Feb 2003 15:39:05 -0000      1.6
  @@ -54,9 +54,11 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.turbine.Turbine;
   import org.apache.turbine.TurbineConstants;
  -import org.apache.turbine.services.resources.TurbineResources;
  +
   import org.apache.turbine.util.RunData;
  +
   import org.apache.velocity.context.Context;
   
   /**
  @@ -64,9 +66,11 @@
    * error template defined in template.error.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Gonzalo Diethelm</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class VelocityErrorScreen extends VelocityScreen
  +public class VelocityErrorScreen
  +    extends VelocityScreen
   {
       /**
        * Implement this to add information to the context.
  @@ -81,8 +85,11 @@
           context.put("processingException",
                   data.getStackTraceException().toString());
           context.put("stackTrace", data.getStackTrace());
  -        String errorTemplate = TurbineResources.getString(
  -                TurbineConstants.TEMPLATE_ERROR_KEY, "error.vm");
  +
  +        String errorTemplate = Turbine.getConfiguration()
  +            .getString(TurbineConstants.TEMPLATE_ERROR_KEY,
  +                       TurbineConstants.TEMPLATE_ERROR_VM);
  +
           setTemplate(data, errorTemplate);
       }
   }
  
  
  
  1.5       +23 -8     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityScreen.java
  
  Index: VelocityScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/VelocityScreen.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VelocityScreen.java       12 Feb 2003 17:52:19 -0000      1.4
  +++ VelocityScreen.java       28 Feb 2003 15:39:05 -0000      1.5
  @@ -54,13 +54,22 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.lang.StringUtils;
  +
   import org.apache.commons.lang.exception.ExceptionUtils;
  +
   import org.apache.ecs.ConcreteElement;
   import org.apache.ecs.StringElement;
  -import org.apache.turbine.services.resources.TurbineResources;
  +
  +import org.apache.turbine.Turbine;
  +import org.apache.turbine.TurbineConstants;
  +
   import org.apache.turbine.services.template.TurbineTemplate;
  +
   import org.apache.turbine.services.velocity.TurbineVelocity;
  +
   import org.apache.turbine.util.RunData;
  +
   import org.apache.velocity.context.Context;
   
   /**
  @@ -74,9 +83,11 @@
    * class and override the doBuildTemplate() method.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class VelocityScreen extends TemplateScreen
  +public class VelocityScreen
  +    extends TemplateScreen
   {
       /**
        * Velocity Screens extending this class should overide this
  @@ -114,7 +125,8 @@
        * @return A ConcreteElement.
        * @exception Exception, a generic exception.
        */
  -    public ConcreteElement buildTemplate(RunData data) throws Exception
  +    public ConcreteElement buildTemplate(RunData data)
  +        throws Exception
       {
           StringElement output = null;
           String screenData = null;
  @@ -153,10 +165,13 @@
               // If there is an error, build a $processingException and
               // attempt to call the error.vm template in the screens
               // directory.
  -            context.put("processingException", e.toString());
  -            context.put("stackTrace", ExceptionUtils.getStackTrace(e));
  -            templateName = TurbineResources.getString(
  -                    "template.error", "/error.vm");
  +            context.put ("processingException", e.toString());
  +            context.put ("stackTrace", ExceptionUtils.getStackTrace(e));
  +
  +            templateName = Turbine.getConfiguration()
  +                .getString(TurbineConstants.TEMPLATE_ERROR_KEY,
  +                           TurbineConstants.TEMPLATE_ERROR_VM);
  +
               if ((templateName.length() > 0) &&
                       (templateName.charAt(0) != '/'))
               {
  
  
  
  1.4       +13 -5     
jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/error/InvalidState.java
  
  Index: InvalidState.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/screens/error/InvalidState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InvalidState.java 12 Feb 2003 17:52:20 -0000      1.3
  +++ InvalidState.java 28 Feb 2003 15:39:05 -0000      1.4
  @@ -56,8 +56,11 @@
   
   import org.apache.ecs.ConcreteElement;
   import org.apache.ecs.ElementContainer;
  +
   import org.apache.ecs.html.A;
  +
   import org.apache.turbine.modules.Screen;
  +
   import org.apache.turbine.util.DynamicURI;
   import org.apache.turbine.util.ParameterParser;
   import org.apache.turbine.util.RunData;
  @@ -74,9 +77,11 @@
    * value and redirect you to this screen.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
  -public class InvalidState extends Screen
  +public class InvalidState
  +    extends Screen
   {
       /**
        * Build the Screen.
  @@ -103,9 +108,12 @@
           ParameterParser pp;
           pp = (ParameterParser) data.getUser().getTemp("prev_parameters");
           pp.remove("_session_access_counter");
  -        message.addElement(new A().setHref(
  -                new DynamicURI(data, (String) data.getUser().getTemp("prev_screen"))
  -                .addPathInfo(pp).toString()).addElement("here"));
  +
  +        DynamicURI back = new DynamicURI(data, (String) 
data.getUser().getTemp("prev_screen"));
  +        back.addPathInfo(pp);
  +
  +        message.addElement(new A().setHref(back.toString()).addElement("here"));
  +
           message.addElement(" to return the the screen you were working on.");
   
           body.addElement(message);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to