Quantcast
Channel: OmniFaces & JSF Fans
Viewing all articles
Browse latest Browse all 74

CDI-JSF: Referencing a producer method via an EL name

$
0
0
Here it is an example of using referencing a producer method via an EL name. The EL expressions used in the JSF page:

#{someFoo}
#{moreFoo}

The Fooqualifier:

@Qualifier
@Retention(RUNTIME)
@Target({METHOD, FIELD, PARAMETER, TYPE})
public @interface Foo {
}

And the bean containing the producer method:

@Named
@ApplicationScoped
public class TheBean {

 @Produces
 @Named
 @Foo
 String getSomeFoo() {
  return "foo";
 }       
   
 @Produces
 @Named("moreFoo")
 @Foo
 String getExtraFoo() {
  return "extra-foo";
 }  
}

The complete example is available here.

Viewing all articles
Browse latest Browse all 74

Trending Articles