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}
#{moreFoo}
The Foo
qualifier:
@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.
Why do you need the foo qualifier? It also works without the @Foo.
RăspundețiȘtergereYeap! You can use it without also :)
RăspundețiȘtergere