1 5 package com.opensymphony.webwork.views.velocity; 6 7 import com.opensymphony.xwork.util.OgnlValueStack; 8 import org.apache.velocity.VelocityContext; 9 10 11 15 public class WebWorkVelocityContext extends VelocityContext { 16 18 OgnlValueStack stack; 19 VelocityContext[] chainedContexts; 20 21 23 public WebWorkVelocityContext(OgnlValueStack stack) { 24 this(null, stack); 25 } 26 27 public WebWorkVelocityContext(VelocityContext[] chainedContexts, OgnlValueStack stack) { 28 this.chainedContexts = chainedContexts; 29 this.stack = stack; 30 } 31 32 34 public boolean internalContainsKey(Object key) { 35 boolean contains = super.internalContainsKey(key); 36 37 if (contains) { 39 return true; 40 } 41 42 if (stack != null) { 44 Object o = stack.findValue(key.toString()); 45 46 if (o != null) { 47 return true; 48 } 49 } 50 51 if (chainedContexts != null) { 53 for (int index = 0; index < chainedContexts.length; index++) { 54 if (chainedContexts[index].containsKey(key)) { 55 return true; 56 } 57 } 58 } 59 60 return false; 62 } 63 64 public Object internalGet(String key) { 65 if (super.internalContainsKey(key)) { 67 return super.internalGet(key); 68 } 69 70 if (stack != null) { 72 Object object = stack.findValue(key); 73 74 if (object != null) { 75 return object; 76 } 77 } 78 79 if (chainedContexts != null) { 81 for (int index = 0; index < chainedContexts.length; index++) { 82 if (chainedContexts[index].containsKey(key)) { 83 return chainedContexts[index].internalGet(key); 84 } 85 } 86 } 87 88 return null; 90 } 91 } 92 | Popular Tags |