1 25 package org.ofbiz.webapp.taglib; 26 27 import java.util.ResourceBundle ; 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.jsp.JspException ; 30 import javax.servlet.jsp.tagext.TagSupport ; 31 32 import org.ofbiz.base.util.Debug; 33 import org.ofbiz.base.util.UtilHttp; 34 import org.ofbiz.base.util.UtilJ2eeCompat; 35 import org.ofbiz.base.util.UtilProperties; 36 37 47 public class I18nBundleTag extends TagSupport { 48 49 public static final String module = I18nBundleTag.class.getName(); 50 51 private String baseName = null; 52 53 private ResourceBundle bundle = null; 54 55 public void setBaseName(String baseName) { 56 this.baseName = baseName; 57 } 58 59 public String getBaseName() { 60 return this.baseName; 61 } 62 63 public void setBundle(ResourceBundle bundle) { 64 this.bundle = bundle; 65 } 66 67 public ResourceBundle getBundle() { 68 return this.bundle; 69 } 70 71 public int doStartTag() throws JspException { 72 try { 73 this.bundle = UtilProperties.getResourceBundle(this.baseName, UtilHttp.getLocale((HttpServletRequest ) pageContext.getRequest())); 74 75 if (this.getId() != null) { 76 pageContext.setAttribute(this.getId(), this.bundle); 77 } 78 } catch (Exception e) { 79 if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { 80 throw new JspException (e.getMessage(), e); 81 } else { 82 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); 83 throw new JspException (e.toString()); 84 } 85 } 86 87 return EVAL_BODY_INCLUDE; 88 } 89 90 public int doEndTag() throws JspException { 91 return EVAL_PAGE; 92 } 93 } 94 | Popular Tags |