| 1 34 35 package com.micronova.util; 36 37 import javax.servlet.http.*; 38 import javax.servlet.jsp.*; 39 import java.util.*; 40 import com.micronova.jsp.tag.*; 41 42 43 44 public class PageContextMap extends NestedMap 45 { 46 protected PageContext _pageContext; 47 protected int _scope; 48 49 public PageContextMap(PageContext pageContext, int scope, List list) 50 { 51 super(); 52 53 _pageContext = pageContext; 54 _scope = scope; 55 56 Enumeration enumeration = null; 57 58 if ((list != null) && (!list.isEmpty())) 59 { 60 enumeration = Collections.enumeration(list); 61 } 62 63 if (enumeration == null) 64 { 65 67 if (scope == PageContext.SESSION_SCOPE) 68 { 69 enumeration = ((HttpServletRequest)_pageContext.getRequest()).getSession().getAttributeNames(); 70 } 71 else 72 { 73 enumeration = _pageContext.getAttributeNamesInScope(_scope); 74 } 75 } 76 77 while (enumeration.hasMoreElements()) 78 { 79 String name = enumeration.nextElement().toString(); 80 this.put(name, pageContext.getAttribute(name, _scope)); 81 } 82 } 83 84 public PageContextMap(PageContext pageContext, int scope) 85 { 86 this(pageContext, scope, null); 87 } 88 89 public PageContext getPageContext() 90 { 91 return _pageContext; 92 } 93 94 public int getScope() 95 { 96 return _scope; 97 } 98 99 public Object putObject(Object objectSource, Object key, Object value) 100 { 101 String keyString = key.toString(); 102 PageContext pageContext = _pageContext; 103 104 YuzuTag.setScopedAttribute(pageContext, keyString, value, _scope); 105 106 return super.putObject(objectSource, key, value); 107 } 108 } 109 | Popular Tags |