1 20 package org.enhydra.barracuda.core.comp; 21 22 import org.apache.log4j.*; 23 import java.util.*; 24 25 import org.enhydra.barracuda.plankton.l10n.*; 26 27 28 29 33 public class DefaultPropertiesModel extends AbstractTemplateModel { 34 35 protected static final Logger logger = Logger.getLogger(DefaultPropertiesModel.class.getName()); 37 38 private final String DEFAULT_RESOURCE = "DefaultResource"; 39 40 protected String modelName = null; 41 protected String propFileName = null; 42 43 44 public DefaultPropertiesModel() { 46 super(); 47 } 48 49 public DefaultPropertiesModel(String ipropFileName) { 50 setPropFileName(ipropFileName); 51 } 52 53 54 public void setPropFileName(String ipropFileName) { 56 propFileName = ipropFileName; 58 59 if (propFileName!=null) { 63 int pos = propFileName.lastIndexOf("."); 64 if (pos>-1) modelName = propFileName.substring(pos+1); 65 else modelName = propFileName; 66 } 67 } 68 69 70 71 public String getName() { 73 return modelName; 74 } 75 76 public Object getItem(String key) { 78 84 ViewContext vc = getViewContext(); 86 Locale targetLocale = vc.getViewCapabilities().getClientLocale(); 87 88 ResourceBundle rb = ResourceBundle.getBundle(propFileName, targetLocale, Thread.currentThread().getContextClassLoader()); 100 102 return Localize.getString(rb, key); 104 } 105 } | Popular Tags |