@Test public void testFindObjectByProperty() { Map<String, Object> requestScope = new HashMap<String, Object>(); Map<String, Object> sessionScope = new HashMap<String, Object>(); Map<String, Object> applicationScope = new HashMap<String, Object>(); requestScope.put("object1", "value"); sessionScope.put("object2", new Integer(1)); applicationScope.put("object3", new Float(2.0)); Request request = createMock(Request.class); expect(request.getContext("request")).andReturn(requestScope) .anyTimes(); expect(request.getContext("session")).andReturn(sessionScope) .anyTimes(); ApplicationContext applicationContext = createMock(ApplicationContext.class); expect(request.getContext("application")).andReturn( applicationScope).anyTimes(); expect(request.getAvailableScopes()).andReturn( Arrays.asList(new String[] { "request", "session", "application" })) .anyTimes(); replay(request, applicationContext); ELContext context = new ELContextImpl(resolver); context.putContext(Request.class, request); context.putContext(ApplicationContext.class, applicationContext); assertEquals("The value is not correct", "value", resolver .findObjectByProperty(context, "object1")); assertEquals("The value is not correct", new Integer(1), resolver .findObjectByProperty(context, "object2")); assertEquals("The value is not correct", new Float(2.0), resolver .findObjectByProperty(context, "object3")); }
protected Object findObjectByProperty(ELContext context, Object property) { Object retValue = null; Request request = (Request) context .getContext(Request.class); String prop = property.toString(); String[] scopes = request.getAvailableScopes().toArray(new String[0]); int i = 0; do { retValue = getObject(request.getContext(scopes[i]), prop); i++; } while (retValue == null && i < scopes.length); return retValue; }
TilesContextBeanELResolver extends ELResolver { protected Object findObjectByProperty(ELContext context, Object property) { Object retValue = null; Request request = (Request) context .getContext(Request.class); String prop = property.toString(); String[] scopes = request.getAvailableScopes().toArray(new String[0]); int i = 0; do { retValue = getObject(request.getContext(scopes[i]), prop); i++; } while (retValue == null && i < scopes.length); return retValue; } }
TilesContextBeanELResolver extends ELResolver { protected Object findObjectByProperty(ELContext context, Object property) { Object retValue = null; Request request = (Request) context .getContext(Request.class); String prop = property.toString(); String[] scopes = request.getAvailableScopes().toArray(new String[0]); int i = 0; do { retValue = getObject(request.getContext(scopes[i]), prop); i++; } while (retValue == null && i < scopes.length); return retValue; }  }
TilesContextBeanELResolver extends ELResolver { protected Object findObjectByProperty(ELContext context, Object property) { Object retValue = null; Request request = (Request) context .getContext(Request.class); String prop = property.toString(); String[] scopes = request.getAvailableScopes().toArray(new String[0]); int i = 0; do { retValue = getObject(request.getContext(scopes[i]), prop); i++; } while (retValue == null && i < scopes.length); return retValue; }  @Override Class<?> getCommonPropertyType(ELContext context, Object base); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
            Object base); @Override Class<?> getType(ELContext context, Object base, Object property); @Override Object getValue(ELContext context, Object base, Object property); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override void setValue(ELContext context, Object base, Object property,
            Object value); }
TilesContextBeanELResolver extends ELResolver { protected Object findObjectByProperty(ELContext context, Object property) { Object retValue = null; Request request = (Request) context .getContext(Request.class); String prop = property.toString(); String[] scopes = request.getAvailableScopes().toArray(new String[0]); int i = 0; do { retValue = getObject(request.getContext(scopes[i]), prop); i++; } while (retValue == null && i < scopes.length); return retValue; }  @Override Class<?> getCommonPropertyType(ELContext context, Object base); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
            Object base); @Override Class<?> getType(ELContext context, Object base, Object property); @Override Object getValue(ELContext context, Object base, Object property); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override void setValue(ELContext context, Object base, Object property,
            Object value);  }