01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.script.el;
20:
21: import javax.servlet.jsp.el.VariableResolver;
22: import javax.servlet.jsp.el.ELException;
23:
24: import org.apache.beehive.netui.util.logging.Logger;
25:
26: /**
27: *
28: */
29: public class NetUIReadVariableResolver extends NetUIVariableResolver {
30:
31: private static final Logger LOGGER = Logger
32: .getInstance(NetUIReadVariableResolver.class);
33:
34: private VariableResolver _vr = null;
35: private Object _actionForm = null;
36:
37: public NetUIReadVariableResolver(VariableResolver vr) {
38: assert vr != null;
39: _vr = vr;
40: }
41:
42: public void setActionForm(Object actionForm) {
43: _actionForm = actionForm;
44: }
45:
46: public Object resolveVariable(String name) {
47: if (name == null)
48: return null;
49:
50: try {
51: if (name.equals("actionForm"))
52: return _actionForm;
53: else
54: return _vr.resolveVariable(name);
55: } catch (ELException e) {
56: String message = "Could not resolve variable named \""
57: + name + "\". Cause: " + e;
58: LOGGER.error(message, e);
59: throw new RuntimeException(message, e);
60: }
61: }
62:
63: public String[] getAvailableVariables() {
64: return new String[] { "actionForm", "pageFlow", "globalApp",
65: "request", "session", "application", "pageContext",
66: "bundle", "container", "url", "pageInput" };
67: }
68: }
|