I have a JSF 2 application that includes a jar file which in turn contains a faces-config.xml in its META-INF directory. The faces-config.xml contains a declaration of a phase-listener. I would like to prevent the installation of this phase listener without modifying the jar file itself. Is this possible?
Asked
Active
Viewed 230 times
1 Answers
4
You can't block specific parts of faces-config.xml in a 3rd party JAR from being interpreted.
You have basically 2 options:
Block the whole
faces-config.xmlin a 3rd party JAR from being interpreted by addingmetadata-complete="true"to webapp's ownfaces-config.xml.<faces-config ... metadata-complete="true">Note that this also skips annotation scans in classes of the 3rd party JAR. You'd basically need to redefine specific parts you'd like to use in webapp's own
faces-config.xml.Provide a custom
Lifecycleimplementation viaLifecycleFactorywhich you register in<factory><lifecycle-factory>of webapp'sfaces-config.xml. In that implementation, overrideaddPhaseListener()accordingly to perform e.g. aninstanceofcheck before skipping or continuing.
BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
option 2 is probably the simplest thing for me considering there are multiple other 3rd party library's I want to behave properly. – cyberoblivion Mar 22 '13 at 15:48
-
A third option, beyond your control, would be to post a feature request to the library vendor that the phase listener should skip its job when e.g. a certain context parameter, or request parameter, or session attribute, or even an environment variable is present, depending on the phase listener's actual job/responsibility. – BalusC Mar 22 '13 at 15:52