Previous Section  < Day Day Up >  Next Section

D.2 Package javax.faces.application

Application

A single instance of a subclass of this abstract class per application creates instances of pluggable application classes or the default class if no customized version is registered.

Synopsis

Class name:

javax.faces.application.Application

Extends:

None

Implements:

None

Constructors


public Application()

Creates an instance.

Methods


public abstract void addComponent(String componentType, String componentClassName)

Registers a mapping between a component type ID and a component implementation class name.


public abstract void addConverter(Class targetClass, String converterClassName)

Registers a mapping between a Class and a Converter implementation class name.


public abstract void addConverter(String converterId, String converterClassName)

Registers a mapping between a converter ID and a Converter implementation class name.


public abstract void addValidator(String validatorId, String converterClassName)

Registers a mapping between a validator ID and a Validator implementation class name.


public abstract javax.faces.component.UIComponent


createComponent(String componentType) throws javax.faces.FacesException

Returns a new instance of the UIComponent class registered for the component type ID.


public abstract javax.faces.component.UIComponent createComponent(javax.faces.el.ValueBinding componentBinding, javax.faces.context.FacesContext context, String componentType) throws javax.faces.el.FacesException

Calls the ValueBinding getValue( ) method. If it returns a UIComponent instance, returns it. Otherwise, creates an instance of the class registered for the component type ID, calls the ValueBinding setValue() with the component instance, and returns the component instance.


public abstract javax.faces.convert.Converter createConverter(Class targetClass) throws javax.faces.el.FacesException

Returns a new instance of the Converter class registered for the target Class.


public abstract javax.faces.convert.Converter createConverter(String converterId) throws javax.faces.el.FacesException

Returns a new instance of the Converter class registered for the converter ID.


public abstract javax.faces.el.MethodBinding createMethodBinding(String expr, Class[] params) throws javax.faces.el.ReferenceSyntaxException

Returns a new MethodBinding instance for a method represented by the method binding expression with a signature matching the provided parameter list or that takes no parameters if the parameter list is null or an empty array.


public abstract javax.faces.validator.Validator createValidator(String validatorId)

Returns a new instance of the Validator class registered for the validator ID.


public abstract javax.faces.el.ValueBinding createValueBinding(String expr) throws javax.faces.el.ReferenceSyntaxException

Returns a new ValueBinding instance for representing the EL expression.


public abstract javax.faces.event.ActionListener getActionListener()

Returns an instance of the default ActionListener instance used for ActionSource components within the application. If no custom version is registered, returns an instance that invokes the component's action MethodBinding invoke() method, the applications NavigationHandler handleNavigation() method with the action methods outcome, and the FacesContext renderResponse() method.


public abstract java.util.Iterator getComponentTypes()

Returns an Iterator over all registered component type IDs.


public abstract java.util.Iterator getConverterIds()

Returns an Iterator over all registered converter IDs.


public abstract java.util.Iterator getConverterTypes()

Returns an Iterator over all Class instances for which a Converter is registered.


public abstract java.util.Locale getDefaultLocale()

Returns the default Locale for this application.


public abstract String getDefaultRenderKitId()

Returns the default render kit ID for this application.


public abstract String getMessageBundle()

Returns the base name for the custom message bundle for this application.


public abstract javax.faces.application.NavigationHandler getNavigationHandler()

Returns the NavigationHandler for this application.


public abstract javax.faces.el.PropertyResolver getPropertyResolver()

Returns the PropertyResolver for this application.


public abstract javax.faces.application.StateManager getStateManager()

Returns the StateManager for this application.


public abstract java.util.Iterator getSupportedLocales()

Returns an Iterator over the supported Locales registered for the application.


public abstract java.util.Iterator getValidatorIds()

Returns an Iterator over all registered validator IDs.


public abstract javax.faces.el.VariableResolver getVariableResolver()

Returns the VariableResolver for this application.


public abstract javax.faces.application.ViewHandler getViewHandler()

Returns the ViewHandler for this application.


public abstract setActionListener(javax.faces.event.ActionListener listener)

Registers the default ActionListener to use for all ActionSource components within this application.


public abstract setDefaultLocale(java.util.Locale locale)

Registers the default Locale for this application.


public abstract setDefaultRenderKitId(String renderKitId)

Registers the default render kit ID for this application.


public abstract setMessageBundle(String baseName)

Registers the base name for the resource bundle that must be consulted in addition to the implementation's message resource bundle for this application.


public abstract setNavigationHandler(javax.faces.application.NavigationHandler nh)

Registers a custom NavigationHandler for this application.


public abstract setPropertyResolver(javax.faces.el.PropertyResolver pr)

Registers a custom PropertyResolver for this application.


public abstract setStateManager(javax.faces.application.StateManager sm)

Registers a custom StateManager for this application.


public abstract setSupportedLocales(java.util.Collection locales)

Registers all Locale instances supported in addition to the default locale for this application.


public abstract setVariableResolver(javax.faces.el.VariableResolver vr)

Registers a custom VariableResolver for this application.


public abstract setViewHandler(javax.faces.application.ViewHandler vh)

Registers a custom ViewHandler for this application.

ApplicationFactory

An instance of a subclass of this abstract class is a factory for the Application instance for an application.

Synopsis

Class name:

javax.faces.application.ApplicationFactory

Extends:

None

Implements:

None

Constructors


public ApplicationFactory()

Creates an instance.

Methods


public abstract javax.faces.application.Application getApplication()

Returns the Application instance for this application, which is either an explicitly registered instance or an instance of the default class.


public abstract setApplication(javax.faces.application.Application)

Registers an Application instance for this application.

FacesMessage

This class is the base class for all specific message subclasses. The messages created by a JSF implementation contain localized text for the Locale returned by the UIViewRoot getLocale() method from the resource bundle with the base name returned by the Application getMessageBundle() or the bundle with the base name defined by the FACES_MESSAGES constant, searched in that order.

Synopsis

Class name:

javax.faces.application.FacesMessage

Extends:

None

Implements:

java.io.Serializable

Fields


public static final String FACES_MESSAGES

The base name for the standard messages resource bundle: javax.faces.Messages.


public static final FacesMessage.Serverity SEVERITY_ERROR

The severity level value for error messages.


public static final FacesMessage.Serverity SEVERITY_FATAL

The severity level value for fatal error messages.


public static final FacesMessage.Serverity SEVERITY_INFO

The severity level value for informational messages.


public static final FacesMessage.Serverity SEVERITY_WARN

The severity level value for warning messages.

Constructors


public FacesMessage()

Creates an empty instance.


public FacesMessage(FacesMessage.Severity severity, String summary, String detail)

Creates an instance with the specified severity, summary, and detail texts.


public FacesMessage(String summary)

Creates an instance with the specified summary text.


public FacesMessage(String summary, String detail)

Creates an instance with the specified summary and detail texts.

Methods


public String getDetail()

Returns the detail text or the summary text if no detail text is defined.


public FacesMessage.Severity getSeverity()

Returns the severity level.


public String getSummary()

Returns the summary text or null if no summary text is defined.


public void setDetail(String detail)

Sets the detail text.


public void setSeverity(FacesMessage.Severity severity)

Sets the severity level.


public void setSummary(String summary)

Sets the summary text.

FacesMessage.Severity

Instances of this nested class represent severity levels for FacesMessage instances. All instances are created by the FacesMessage class and made available through public final static fields, with ordinal values in the order SEVERITY_INFO, SEVERITY_WARN, SEVERITY_ERROR, and SEVERITY_FATAL.

Synopsis

Class name:

javax.faces.application.FacesMessage.Severity

Extends:

None

Implements:

java.lang.Comparable

Methods


public int compareTo(Object other)

Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.


public int getOrdinal()

Returns the ordinal value for this instance.


public String toString()

Returns a String representation of this instance.

NavigationHandler

An instance of a subclass of this abstract class is invoked to handle navigation to different view based on the outcome of an action method. The default implementation behavior is described in Chapter 9.

Synopsis

Class name:

javax.faces.application.NavigationHandler

Extends:

None

Implements:

None

Constructors


public NavigationHandler()

Creates an instance.

Methods


public abstract void handleNavigation(javax.faces.context.FacesContext context,


String fromAction, String outcome)

Selects a new view (or sends a response and calls the FacesContext responseComplete( ) method) based on the provided information about the method binding expression for the action method and the action outcome.

StateManager

An instance of a subclass of this abstract class is invoked to save and restore the state for a view, typically in cooperation with an instance of the javax.faces.render.ResponseStateManager for client-side state saving.

Synopsis

Class name:

javax.faces.application.StateManager

Extends:

None

Implements:

None

Fields


public static final String STATE_SAVING_METHOD_CLIENT

The client-side choice value for the state-saving method selection context initialization parameter: client.


public static final String STATE_SAVING_METHOD_PARAM

The name of the state-saving selection context initialization parameter: javax.faces.STATE_SAVING_METHOD.


public static final String STATE_SAVING_METHOD_SERVER

The server-side choice value for the state-saving method selection context initialization parameter: server.

Constructors


public StateManager()

Creates an instance.

Methods


protected abstract Object getComponentStateToSave(javax.faces.context.FacesContext context)

Returns a Serializable object representing the state of all components and their attached objects.


protected abstract Object getTreeStructureToSave(javax.faces.context.FacesContext context)

Returns a Serializable object representing the component tree structure, i.e., the parent-child relationship for all components and facets in the view.


public boolean isSavingStateInClient()

Returns true if the STATE_SAVING_METHOD_PARAM context initialization parameter has the value STATE_SAVING_METHOD_CLIENT.


protected abstract void restoreComponentState(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot, String renderKitId)

Restores the state of all components in the view being restored.


protected abstract void restoreView(javax.faces.context.FacesContext context, String viewId, String renderKitId)

Restores the view by calling the restoreTreeStructure( ) and restoreComponentState() methods.


public abstract javax.faces.component.UIViewRoot restoreTreeStructure(javax.faces.context.FacesContext context, String viewId, String renderKitId)

Restores the component tree structure for the view being restored.


public abstract StateManager.SerializedView saveSerializedView(javax.faces.context.FacesContext context)

Returns the StateManager.SerializedView for the view, created from the objects created by the getComponentStateToSave() and getTreeStructureToSave() methods.


public abstract void writeState(javax.faces.context.FacesContext context, StateManager.SerializedView state)

Saves the view state, by calling the ResponseStateManager writeState( ) method if isSavingStateInClient() returns true; otherwise in any manner that allows the state to be restored by the restoreView() method.

StateManager.SerializedView

An instance of this nested class represents the saved state for a view.

Synopsis

Class name:

javax.faces.application.StateManager.SerializedView

Extends:

None

Implements:

None

Methods


public Object getState()

Returns the state for the components in the view.


public Object getStructure()

Returns the component tree structure for the view.

ViewHandler

An instance of a subclass of this abstract class is invoked to create a view for a view ID, render the view and save and restore the state for a view, typically in cooperation with an instance of the javax.faces.application.StateManager. It's the main class for a presentation layer technology. See Chapter 15 for details.

Synopsis

Class name:

javax.faces.application.ViewHandler

Extends:

None

Implements:

None

Fields


public static final String CHARACTER_ENCODING_KEY

The name of a session scope variable that holds the character encoding used for the previous response: javax.faces.request.charset.


public static final String DEFAULT_SUFFIX

The default suffix for the resource that represents a view, used together with extension mapping for the FacesServlet: .jsp.


public static final String DEFAULT_SUFFIX_PARAM_NAME

The name of the default suffix declaration context initialization parameter: javax.faces.DEFAULT_SUFFIX.

Constructors


public ViewHandler()

Creates an instance.

Methods


public abstract java.util.Locale


calculateLocale(javax.faces.context.FacesContext context)

Returns the Locale to use for this view. The default implementation returns the first supported locale (including the default locale) that best matches the locales in the Accept-Language header or the default locale if none matches. If no default locale is defined, it returns the default locale for the Java environment.


public abstract String calculateRenderKitId(javax.faces.context.FacesContext context)

Returns the render kit ID to use for this view. The default implementation returns the value returned by Application getDefaultRenderKitId( ) or the value defined by the RenderKitFactory.HTML_BASIC_RENDER_KIT field if there's no default render kit defined for the applications.


public abstract javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context, String viewId)

Returns the UIViewRoot for the identified view, possibly populated with a complete component tree, with the UIViewRoot locale and renderKitId properties initialized.


public abstract String getActionURL(javax.faces.context.FacesContext context, String viewId)

Returns the URL matching the specified view ID, encoded by calling ExternalContext encodeActionURL( ).


public abstract String getResourceURL(javax.faces.context.FacesContext context, String path)

Returns the URL matching the specified path, encoded by calling ExternalContext encodeResourceURL( ). The default implementation prepends the context path to the specified path if it starts with a slash, i.e., converting a context-relative path to the absolute path a browser needs to locate the resource.


public abstract void renderView(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot)

Renders the components in the specified view.


public abstract void renderView(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot)

Renders the components in the specified view.


public abstract javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, String viewId)

Returns the restored UIViewRoot for the identified view or null if there's no state available for the view.


public abstract void writeState(javax.faces.context.FacesContext context)

Writes the state to the response with the help from the StateManager writeState() method or mark where the state needs to be written later.

    Previous Section  < Day Day Up >  Next Section