Coverage Report - org.trails.component.TrailsComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
TrailsComponent
67% 
N/A 
0
 
 1  
 /*
 2  
  * Copyright 2004 Chris Nelson
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 7  
  * Unless required by applicable law or agreed to in writing,
 8  
  * software distributed under the License is distributed on an "AS IS" BASIS,
 9  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 10  
  * See the License for the specific language governing permissions and limitations under the License.
 11  
  */
 12  
 package org.trails.component;
 13  
 
 14  
 import org.apache.tapestry.BaseComponent;
 15  
 import org.apache.tapestry.annotations.InjectObject;
 16  
 import org.trails.i18n.TrailsMessageSource;
 17  
 
 18  
 
 19  
 /**
 20  
  * @author fus8882
 21  
  *         <p/>
 22  
  *         TODO To change the template for this generated type comment go to
 23  
  *         Window - Preferences - Java - Code Style - Code Templates
 24  
  */
 25  68
 public abstract class TrailsComponent extends BaseComponent
 26  
 {
 27  4
         public static String DEFAULT = "Default";
 28  
 
 29  
         /**
 30  
          * Return the Spring TrailsMessageSource. This is used to implement
 31  
          * i18n in all Trails components, accessing a i18n properties file in the
 32  
          * application instead of accessing the property file located in org.trais.component package.
 33  
          * By doing this, someone who would need i18n wouldn't need to change the property
 34  
          * located in the org.trails.component package and rebuild the trails.jar
 35  
          *
 36  
          * @return
 37  
          */
 38  
         @InjectObject("service:trails.core.MessageSource")
 39  
         public abstract TrailsMessageSource getResourceBundleMessageSource();
 40  
 
 41  
         /**
 42  
          * This method will lookup for a message in Trails resource bundle
 43  
          * and return a message, if found, in the default Locale. This is normally called from
 44  
          * Component templates, so messages will be looked up outside the component,
 45  
          * making it easier for an user to localize Trails.
 46  
          */
 47  
         public String getMessage(String key)
 48  
         {
 49  0
                 return getResourceBundleMessageSource().getMessageWithDefaultValue(key, "[TRAILS][" + key.toUpperCase() + "]");
 50  
         }
 51  
 
 52  
 }