001: /*
002: * Copyright 2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package javax.faces.application;
017:
018: import javax.el.ELContextListener;
019: import javax.el.ELException;
020: import javax.el.ELResolver;
021: import javax.el.ExpressionFactory;
022: import javax.el.ValueExpression;
023: import javax.faces.FacesException;
024: import javax.faces.component.UIComponent;
025: import javax.faces.context.FacesContext;
026: import javax.faces.el.ReferenceSyntaxException;
027:
028: import java.util.Collection;
029: import java.util.Iterator;
030: import java.util.Locale;
031: import java.util.ResourceBundle;
032:
033: /**
034: * Holds webapp-wide resources for a JSF application. There is a single one of
035: * these for a web application, accessable via
036: * <pre>
037: * FacesContext.getCurrentInstance().getApplication()
038: * </pre>
039: * In particular, this provides a factory for UIComponent objects.
040: * It also provides convenience methods for creating ValueBinding objects.
041: *
042: * See Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
043: *
044: * @author Manfred Geiler (latest modification by $Author: mbr $)
045: * @author Stan Silvert
046: * @version $Revision: 511493 $ $Date: 2007-02-25 13:54:46 +0100 (So, 25 Feb 2007) $
047: */
048: @SuppressWarnings("deprecation")
049: public abstract class Application {
050:
051: // The following concrete methods were added for JSF 1.2. They supply default
052: // implementations that throw UnsupportedOperationException.
053: // This allows old Application implementations to still work.
054: public void addELResolver(ELResolver resolver) {
055: throw new UnsupportedOperationException();
056: }
057:
058: public ELResolver getELResolver() {
059: throw new UnsupportedOperationException();
060: }
061:
062: public ResourceBundle getResourceBundle(FacesContext ctx,
063: String name) throws FacesException, NullPointerException {
064: throw new UnsupportedOperationException();
065: }
066:
067: public UIComponent createComponent(
068: ValueExpression componentExpression,
069: FacesContext facesContext, String componentType)
070: throws FacesException, NullPointerException {
071: throw new UnsupportedOperationException();
072: }
073:
074: public ExpressionFactory getExpressionFactory() {
075: throw new UnsupportedOperationException();
076: }
077:
078: public void addELContextListener(ELContextListener listener) {
079: throw new UnsupportedOperationException();
080: }
081:
082: public void removeELContextListener(ELContextListener listener) {
083: throw new UnsupportedOperationException();
084: }
085:
086: public ELContextListener[] getELContextListeners() {
087: throw new UnsupportedOperationException();
088: }
089:
090: public Object evaluateExpressionGet(FacesContext context,
091: String expression, Class expectedType) throws ELException {
092: throw new UnsupportedOperationException();
093: }
094:
095: // -------- abstract methods -------------------
096: public abstract javax.faces.event.ActionListener getActionListener();
097:
098: public abstract void setActionListener(
099: javax.faces.event.ActionListener listener);
100:
101: public abstract Locale getDefaultLocale();
102:
103: public abstract void setDefaultLocale(Locale locale);
104:
105: public abstract String getDefaultRenderKitId();
106:
107: public abstract void setDefaultRenderKitId(String renderKitId);
108:
109: public abstract String getMessageBundle();
110:
111: public abstract void setMessageBundle(String bundle);
112:
113: /**
114: * Return the NavigationHandler object which is responsible for mapping from
115: * a logical (viewid, fromAction, outcome) to the URL of a view to be rendered.
116: */
117: public abstract javax.faces.application.NavigationHandler getNavigationHandler();
118:
119: public abstract void setNavigationHandler(
120: javax.faces.application.NavigationHandler handler);
121:
122: /**
123: * Get the object used by the VariableResolver to read and write named properties
124: * on java beans, Arrays, Lists and Maps. This object is used by the ValueBinding
125: * implementation, and during the process of configuring "managed bean" properties.
126: *
127: * @deprecated
128: */
129: public abstract javax.faces.el.PropertyResolver getPropertyResolver();
130:
131: /**
132: * @deprecated
133: */
134: public abstract void setPropertyResolver(
135: javax.faces.el.PropertyResolver resolver);
136:
137: /**
138: * Get the object used to resolve expressions of form "#{...}".
139: *
140: * @deprecated
141: */
142: public abstract javax.faces.el.VariableResolver getVariableResolver();
143:
144: /**
145: * @deprecated
146: */
147: public abstract void setVariableResolver(
148: javax.faces.el.VariableResolver resolver);
149:
150: public abstract javax.faces.application.ViewHandler getViewHandler();
151:
152: public abstract void setViewHandler(
153: javax.faces.application.ViewHandler handler);
154:
155: public abstract javax.faces.application.StateManager getStateManager();
156:
157: public abstract void setStateManager(
158: javax.faces.application.StateManager manager);
159:
160: /**
161: * Define a new mapping from a logical "component type" to an actual java class name.
162: * This controls what type is created when method createComponent of this class is
163: * called.
164: * <p>
165: * Param componentClass must be the fully-qualified class name of some class
166: * extending the UIComponent class. The class must have a default constructor,
167: * as instances of it will be created using Class.newInstance.
168: * <p>
169: * It is permitted to override a previously defined mapping, ie to call this
170: * method multiple times with the same componentType string. The createComponent
171: * method will simply use the last defined mapping.
172: */
173: public abstract void addComponent(String componentType,
174: String componentClass);
175:
176: /**
177: * Create a new UIComponent subclass, using the mappings defined by previous
178: * calls to the addComponent method of this class.
179: * <p>
180: * @throws FacesException if there is no mapping defined for the specified
181: * componentType, or if an instance of the specified type could not be
182: * created for any reason.
183: */
184: public abstract javax.faces.component.UIComponent createComponent(
185: String componentType) throws FacesException;
186:
187: /**
188: * Create an object which has an associating "binding" expression tying the component
189: * to a user property.
190: * <p>
191: * First the specified value-binding is evaluated; if it returns a non-null value then
192: * the component "already exists" and so the resulting value is simply returned.
193: * <p>
194: * Otherwise a new UIComponent instance is created using the specified componentType,
195: * and the new object stored via the provided value-binding before being returned.
196: *
197: * @deprecated
198: */
199: public abstract javax.faces.component.UIComponent createComponent(
200: javax.faces.el.ValueBinding componentBinding,
201: javax.faces.context.FacesContext context,
202: String componentType) throws FacesException;
203:
204: public abstract Iterator<String> getComponentTypes();
205:
206: public abstract void addConverter(String converterId,
207: String converterClass);
208:
209: public abstract void addConverter(Class targetClass,
210: String converterClass);
211:
212: public abstract javax.faces.convert.Converter createConverter(
213: String converterId);
214:
215: public abstract javax.faces.convert.Converter createConverter(
216: Class targetClass);
217:
218: public abstract Iterator<String> getConverterIds();
219:
220: public abstract Iterator<Class> getConverterTypes();
221:
222: /**
223: * Create an object which can be used to invoke an arbitrary method via an
224: * EL expression at a later time. This is similar to createValueBinding
225: * except that it can invoke an arbitrary method (with parameters) rather
226: * than just get/set a javabean property.
227: * <p>
228: * This is used to invoke ActionListener method, and ValueChangeListener
229: * methods.
230: *
231: * @deprecated
232: */
233: public abstract javax.faces.el.MethodBinding createMethodBinding(
234: String ref, Class[] params) throws ReferenceSyntaxException;
235:
236: public abstract Iterator<Locale> getSupportedLocales();
237:
238: public abstract void setSupportedLocales(Collection<Locale> locales);
239:
240: public abstract void addValidator(String validatorId,
241: String validatorClass);
242:
243: public abstract javax.faces.validator.Validator createValidator(
244: String validatorId) throws FacesException;
245:
246: public abstract Iterator<String> getValidatorIds();
247:
248: /**
249: * Create an object which can be used to invoke an arbitrary method via an
250: * EL expression at a later time. This is similar to createValueBinding
251: * except that it can invoke an arbitrary method (with parameters) rather
252: * than just get/set a javabean property.
253: * <p>
254: * This is used to invoke ActionListener method, and ValueChangeListener
255: * methods.
256: *
257: * @deprecated
258: */
259: public abstract javax.faces.el.ValueBinding createValueBinding(
260: String ref) throws ReferenceSyntaxException;
261: }
|