001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.pageflow.faces.internal;
020:
021: import org.apache.beehive.netui.pageflow.internal.InternalConstants;
022: import org.apache.beehive.netui.util.logging.Logger;
023:
024: import javax.faces.FacesException;
025: import javax.faces.application.Application;
026: import javax.faces.application.NavigationHandler;
027: import javax.faces.application.StateManager;
028: import javax.faces.application.ViewHandler;
029: import javax.faces.component.UIComponent;
030: import javax.faces.context.FacesContext;
031: import javax.faces.convert.Converter;
032: import javax.faces.el.MethodBinding;
033: import javax.faces.el.PropertyResolver;
034: import javax.faces.el.ReferenceSyntaxException;
035: import javax.faces.el.ValueBinding;
036: import javax.faces.el.VariableResolver;
037: import javax.faces.event.ActionListener;
038: import javax.faces.validator.Validator;
039: import java.util.Collection;
040: import java.util.Iterator;
041: import java.util.Locale;
042:
043: /**
044: * Internal class used in JSF/Page Flow integration. This is the main hook for overriding base JSF behavior.
045: * @see org.apache.beehive.netui.pageflow.faces.PageFlowApplicationFactory
046: */
047: public class PageFlowApplication extends Application {
048: private static final String BACKING_BINDING_START = "#{"
049: + InternalConstants.BACKING_CLASS_IMPLICIT_OBJECT + '.';
050:
051: private static final Logger _log = Logger
052: .getInstance(PageFlowApplication.class);
053:
054: private Application _delegate;
055:
056: public PageFlowApplication(Application delegate) {
057: if (_log.isDebugEnabled()) {
058: _log.debug("Adapting Application" + delegate);
059: }
060:
061: _delegate = delegate;
062: }
063:
064: public ActionListener getActionListener() {
065: return _delegate.getActionListener();
066: }
067:
068: public void setActionListener(ActionListener listener) {
069: _delegate
070: .setActionListener(new PageFlowActionListener(listener));
071: }
072:
073: public Locale getDefaultLocale() {
074: return _delegate.getDefaultLocale();
075: }
076:
077: public void setDefaultLocale(Locale locale) {
078: _delegate.setDefaultLocale(locale);
079: }
080:
081: public String getDefaultRenderKitId() {
082: return _delegate.getDefaultRenderKitId();
083: }
084:
085: public void setDefaultRenderKitId(String renderKitId) {
086: _delegate.setDefaultRenderKitId(renderKitId);
087: }
088:
089: public String getMessageBundle() {
090: return _delegate.getMessageBundle();
091: }
092:
093: public void setMessageBundle(String bundle) {
094: _delegate.setMessageBundle(bundle);
095: }
096:
097: public NavigationHandler getNavigationHandler() {
098: return _delegate.getNavigationHandler();
099: }
100:
101: public void setNavigationHandler(NavigationHandler handler) {
102: _delegate.setNavigationHandler(new PageFlowNavigationHandler(
103: handler));
104: }
105:
106: public PropertyResolver getPropertyResolver() {
107: return _delegate.getPropertyResolver();
108: }
109:
110: public void setPropertyResolver(PropertyResolver resolver) {
111: _delegate.setPropertyResolver(resolver);
112: }
113:
114: public VariableResolver getVariableResolver() {
115: return _delegate.getVariableResolver();
116: }
117:
118: public void setVariableResolver(VariableResolver resolver) {
119: _delegate.setVariableResolver(resolver);
120: }
121:
122: public ViewHandler getViewHandler() {
123: return _delegate.getViewHandler();
124: }
125:
126: public void setViewHandler(ViewHandler handler) {
127: _delegate
128: .setViewHandler(handler instanceof PageFlowViewHandler ? handler
129: : new PageFlowViewHandler(handler));
130: }
131:
132: public StateManager getStateManager() {
133: return _delegate.getStateManager();
134: }
135:
136: public void setStateManager(StateManager manager) {
137: _delegate.setStateManager(manager);
138: }
139:
140: public void addComponent(String componentType, String componentClass) {
141: _delegate.addComponent(componentType, componentClass);
142: }
143:
144: public UIComponent createComponent(String componentType)
145: throws FacesException {
146: return _delegate.createComponent(componentType);
147: }
148:
149: public UIComponent createComponent(ValueBinding componentBinding,
150: FacesContext context, String componentType)
151: throws FacesException {
152: return _delegate.createComponent(componentBinding, context,
153: componentType);
154: }
155:
156: public Iterator getComponentTypes() {
157: return _delegate.getComponentTypes();
158: }
159:
160: public void addConverter(String converterId, String converterClass) {
161: _delegate.addConverter(converterId, converterClass);
162: }
163:
164: public void addConverter(Class targetClass, String converterClass) {
165: _delegate.addConverter(targetClass, converterClass);
166: }
167:
168: public Converter createConverter(String converterId) {
169: return _delegate.createConverter(converterId);
170: }
171:
172: public Converter createConverter(Class targetClass) {
173: return _delegate.createConverter(targetClass);
174: }
175:
176: public Iterator getConverterIds() {
177: return _delegate.getConverterIds();
178: }
179:
180: public Iterator getConverterTypes() {
181: return _delegate.getConverterTypes();
182: }
183:
184: public MethodBinding createMethodBinding(String ref, Class params[])
185: throws ReferenceSyntaxException {
186: MethodBinding mb = _delegate.createMethodBinding(ref, params);
187:
188: if (ref.startsWith(BACKING_BINDING_START)
189: && ref.charAt(ref.length() - 1) == '}') {
190: String methodName = ref.substring(BACKING_BINDING_START
191: .length(), ref.length() - 1);
192: return new BackingClassMethodBinding(methodName, params, mb);
193: } else {
194: return mb;
195: }
196: }
197:
198: public Iterator getSupportedLocales() {
199: return _delegate.getSupportedLocales();
200: }
201:
202: public void setSupportedLocales(Collection locales) {
203: _delegate.setSupportedLocales(locales);
204: }
205:
206: public void addValidator(String validatorId, String validatorClass) {
207: _delegate.addValidator(validatorId, validatorClass);
208: }
209:
210: public Validator createValidator(String validatorId)
211: throws FacesException {
212: return _delegate.createValidator(validatorId);
213: }
214:
215: public Iterator getValidatorIds() {
216: return _delegate.getValidatorIds();
217: }
218:
219: public ValueBinding createValueBinding(String ref)
220: throws ReferenceSyntaxException {
221: return _delegate.createValueBinding(ref);
222: }
223: }
|