You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Motivation

The JSF module provides additional features like new scopes and it improves existing JSF mechanisms.

Dependencies

The page CODI Modules provides an overview about CODI modules and how to add them to your project.

For using the features described in JSF Usage, you have to add:

  • CODI-Core
  • CODI-JSF module (for the JSF version you are using)
  • CODI-Message- and BV-Module
  • JSF implementation of your choice

Compatibility

This module is tested with JSF 1.2, 2.0 and 2.1

Details

Further details related to this module are available at:

Overview

Scopes

Grouped Conversation Scope

CDI conversations are very limited. Therefore CODI provides grouped conversations which are similar to the conversations of MyFaces Orchestra. Compared to std. CDI conversations CODI provides completely different conversation concepts. "Just the name is the same." Every conversation scoped bean (or a group of beans) has/have a conversation. So it's possible to have multiple conversations in parallel (in the same window) with a different lifetime. Optionally you can use a fine grained memory management. You can easily just end the conversation of a single bean (or a group of conversation scoped beans) or all conversations within the current window.

View Access Scope

Normally you have to terminate conversations manually (or they will be terminated automatically after a timeout). However, sometimes you need beans with a lifetime which is as long as needed and as short as possible which are terminated automatically (as soon as possible). In such an use-case you can use this scope. The simple rule is, as long as the bean is referenced by a page - the bean will be available for the next page (if it's used again the bean will be forwarded again).

Window Scope

This scope is comparable with a session per window. It is useful for beans which contain e.g. preferences of the current user.

View Scope (JSF 2+ only)

CODI allows using all CDI mechanisms for the new view scope of JSF 2.

Dependency Injection

CODI allows using @Inject within the following JSF artifacts:

  • Converter
  • Validator
  • PhaseListener

Life-cycle Annotations

Phase-Listener Methods

Sometimes you don't need a full Phase-Listener. So CODI allows to annotate individual methods. Furthermore, it's possible to link those methods to special views.

Phase-Listener

JSF itself doesn't provide an annotation for phase-listeners. CODI provides such an annotation. Furthermore, CODI provides an optional annotation to define the invocation order of phase-listeners.

Faces-Request-Listener

Methods annotated with these annotations are invoked before and after a faces-request. In comparison to similar mechanisms, the FacesContext is available for the listener.

Producers

Producers for JSF artifacts

  • FacesContext

Producers for CODI artifacts

  • WindowContextManager
  • WindowContext
  • Conversation
  • MessageContext

Type-safe View Config

View configs are the base mechanism for type-safe navigation and further concepts like page-beans. It's planned to add further features based on this type-safe config approach. Furthermore, it's possible to create custom meta-data for a view.

Type-safe Navigation

Instead of using strings as outcome, it's possible to link a page to a special config class. So it's possible to use these classes as return values for action methods.

PreViewConfigNavigateEvent

In case of type-safe navigation it's possible to observe navigations which have a view-config for the source-view as well as the target-view.
Furthermore, it's possible to change the navigation target.

Type-safe Security

It's possible to define permissions per method, bean, page or group of pages. You can use a custom implementation or an adapter to integrate an external security framework.

JsfLifecyclePhaseInformation

Helper for detecting the current phase of the JSF request lifecycle.

RequestTypeResolver

It's mainly for used internally. However, you can use it to easily detect the type of the current request and it's possible to plugin a custom implementation which gets used by the framework.

Startup-Event (v0.9.2+)

This event gets fired as soon as the application is initialized.
(Currently only the JSF module supports the event out-of-the-box and triggers it lazily before the first request gets processed.)

ViewNavigationHandler (v0.9.2+)

If manual navigation is needed, it's possible to inject a simple(r) navigation handler which uses the type-safe view-config approach of CODI for navigation and allows an easier navigation due to a simple API.

Injectable Logger (v0.9.2+)

Per default it isn't possible to inject loggers. CODI allows to inject a serializable java.util.Logger.

Navigation to the default error view (v0.9.2+)

If an add-on has to trigger navigation to the default error view or it's desired to use an error-handling module across applications, it's possible to use DefaultErrorView to navigate to the configured error-view.

Special support for testing (v0.9.2+)

CODI provides a base-test-infrastructure module which allows easier JUnit and Cargo tests for CDI as well as JSF based applications.

Qualifiers

Esp. the JSF qualifier provided by CODI allows injecting pre-configured artifacts.

  • No labels