Java Reference
In-Depth Information
Again, there is nothing special we need to do to access the named bean's properties
from the above markup, it works just as if the bean was a JSF-managed bean. The
above page renders as follows:
As we can see, CDI applications work just like JSF applications, however, CDI
applications have several advantages over JSF. For example, like as we previously
mentioned, CDI beans have additional scopes not found in JSF. Additionally, using
CDI allows us to decouple our Java code from the JSF API. Also, like we mentioned
previously, CDI allows us to use session beans as named beans.
In some instances the type of the bean we wish to inject into our code may be an
interface or a Java superclass, but we may be interested in injecting a subclass or a
class implementing the interface. For cases like this, CDI provides qualifiers we can
use to indicate the specific type we wish to inject into our code.
A CDI qualifier is an annotation that must be decorated with the @Qualifier
annotation. This annotation can then be used to decorate the specific subclass or
interface. In this section, we will develop a Premium qualifier for our customer bean,
premium customers could get perks, such as discounts, not available to regular
Search WWH ::

Custom Search