nbubna      2003/02/12 16:24:30

  Modified:    struts/src/java/org/apache/velocity/tools/struts
                        MessageTool.java
  Log:
  use Velocity's log system and drop unnecessary members
  
  Revision  Changes    Path
  1.6       +10 -35    
jakarta-velocity-tools/struts/src/java/org/apache/velocity/tools/struts/MessageTool.java
  
  Index: MessageTool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity-tools/struts/src/java/org/apache/velocity/tools/struts/MessageTool.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MessageTool.java  10 May 2002 05:42:17 -0000      1.5
  +++ MessageTool.java  13 Feb 2003 00:24:30 -0000      1.6
  @@ -64,6 +64,7 @@
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.action.*;
   
  +import org.apache.velocity.app.Velocity;
   import org.apache.velocity.tools.view.context.ViewContext;
   import org.apache.velocity.tools.view.tools.ViewTool;
   
  @@ -90,24 +91,6 @@
       // --------------------------------------------- Properties -------
   
       /**
  -     * A reference to the ServletContext
  -     */ 
  -    protected ServletContext application;
  -
  -
  -    /**
  -     * A reference to the HttpServletRequest.
  -     */ 
  -    protected HttpServletRequest request;
  -    
  -
  -    /**
  -     * A reference to the HtttpSession.
  -     */ 
  -    protected HttpSession session;
  -
  -
  -    /**
        * A reference to the Struts message resources.
        */
       protected MessageResources resources;
  @@ -144,20 +127,12 @@
           }
   
           ViewContext context = (ViewContext)obj;
  -        this.request = context.getRequest();
  -        this.session = request.getSession(false);
  -        this.application = context.getServletContext();    
  +        HttpServletRequest request = context.getRequest();
  +        HttpSession session = request.getSession(false);
  +        ServletContext application = context.getServletContext();    
   
  -        resources = StrutsUtils.getMessageResources(application);
  -        locale = StrutsUtils.getLocale(request, session);
  -    }
  -    
  -    
  -    /**
  -     * Log messages are sent to the servlet context
  -     */
  -    private void log(String s) {
  -        application.log(s);
  +        this.resources = StrutsUtils.getMessageResources(application);
  +        this.locale = StrutsUtils.getLocale(request, session);
       }
   
   
  @@ -178,7 +153,7 @@
       {
           if (resources == null)
           {
  -            log("[ERROR] Message resources are not available.");
  +            Velocity.error("Message resources are not available.");
               return null;
           }
           return resources.getMessage(locale, key);
  @@ -201,7 +176,7 @@
       {
           if (resources == null)
           {
  -            log("[ERROR] Message resources are not available.");
  +            Velocity.error("Message resources are not available.");
               return null;
           }
           
  @@ -247,7 +222,7 @@
       {
           if (resources == null)
           {
  -            log("[ERROR] Message resources are not available.");
  +            Velocity.error("Message resources are not available.");
               return false;
           }
   
  
  
  

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

Reply via email to