1 28 29 package com.caucho.jstl.rt; 30 31 import com.caucho.jsp.PageContextImpl; 32 import com.caucho.util.L10N; 33 34 import javax.servlet.jsp.JspException ; 35 import javax.servlet.jsp.jstl.fmt.LocalizationContext; 36 import javax.servlet.jsp.tagext.TagSupport ; 37 38 41 public class SetBundleTag extends TagSupport { 42 private static L10N L = new L10N(SetBundleTag.class); 43 44 private String _basename; 45 private String _var = "javax.servlet.jsp.jstl.fmt.localizationContext"; 46 private String _scope; 47 48 51 public void setBasename(String basename) 52 { 53 _basename = basename; 54 } 55 56 59 public void setVar(String var) 60 { 61 _var = var; 62 } 63 64 67 public void setScope(String scope) 68 { 69 _scope = scope; 70 } 71 72 75 public int doStartTag() 76 throws JspException 77 { 78 PageContextImpl pc = (PageContextImpl) pageContext; 79 80 LocalizationContext bundle = pc.getBundle(_basename); 81 82 if (_scope == null || _scope.equals("") || _scope.equals("page")) 83 pc.setAttribute(_var, bundle); 84 else if (_scope.equals("request")) 85 pc.getRequest().setAttribute(_var, bundle); 86 else if (_scope.equals("session")) 87 pc.getSession().setAttribute(_var, bundle); 88 else if (_scope.equals("application")) 89 pc.getServletContext().setAttribute(_var, bundle); 90 else 91 throw new JspException (L.l("unknown scope `{0}' in fmt:setBundle", 92 _scope)); 93 94 return SKIP_BODY; 95 } 96 } 97 | Popular Tags |