Re: JSF 2.3 Section 5.4.1 question regarding injection

Edward Burns

On Tue, 22 Aug 2017 07:18:25 -0700, said:
PN> According to the JSF spec section 5.4.1 JSF Managed Classes and Java
PN> EE Annotations, there are a bunch of JSF artifacts eligible for
PN> injection.

PN> On MyFaces, all these objects allow injection when they are
PN> registered globally via faces-config.xml.  However, injection in
PN> ActionListener and PhaseListener dont work if they are registered
PN> per component/view in a facelet using  <f:actionListener/> and
PN> <f:phaseListener/>.

PN> The following MyFaces JIRA was opened to discuss the issue with the
PN> MyFaces community:

PN> On Mojarra, I was not able to get these objects to support
PN> injection,  I tried registering them globally via faces-config.xml
PN> and registering them per component/view in a facelet.

PN> Does injection in ActionListener or PhaseListener need to be
PN> supported when they are registered in a facelet using
PN> <f:actionListener/> and <f:phaseListener/>?

Hello Paul,

Looking at 5.4.1, there is no specific exclusion for ActionListener or
PhaseListener when they happen to be declared in a Facelet. Indeed,
looking at the code for both tags, I see we simply are just using new.

if (instance == null && type != null) {
try {
instance = (PhaseListener) ReflectionUtil.forName(
} catch (ClassNotFoundException | InstantiationException |
IllegalAccessException e)

I have opened

I propose we add to the errata an issue excluding these two from having
to be injectable when they are created via a facelet.


| 23 business days until JavaOne 2017
| 103 business days until JavaLand 2018
| | office: +1 407 458 0017

Join to automatically receive all group messages.