01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.web.jsf;
18:
19: import javax.faces.context.FacesContext;
20: import javax.faces.el.EvaluationException;
21: import javax.faces.el.VariableResolver;
22:
23: /**
24: * This is a subclass of the JSF 1.1 {@link DelegatingVariableResolver},
25: * letting Spring bean definitions override other attributes of the same name.
26: *
27: * <p>The main purpose of this class is to provide behavior that is analogous
28: * to the JSF 1.2 {@link org.springframework.web.jsf.el.SpringBeanFacesELResolver}.
29: *
30: * @author Juergen Hoeller
31: * @since 2.5
32: * @see WebApplicationContextVariableResolver
33: * @see FacesContextUtils#getRequiredWebApplicationContext
34: */
35: public class SpringBeanVariableResolver extends
36: DelegatingVariableResolver {
37:
38: public SpringBeanVariableResolver(
39: VariableResolver originalVariableResolver) {
40: super (originalVariableResolver);
41: }
42:
43: public Object resolveVariable(FacesContext facesContext, String name)
44: throws EvaluationException {
45: Object bean = resolveSpringBean(facesContext, name);
46: if (bean != null) {
47: return bean;
48: }
49: Object value = resolveOriginal(facesContext, name);
50: if (value != null) {
51: return value;
52: }
53: return null;
54: }
55:
56: }
|