Prevent installation of phase listener from jar enabled in jsf 2

I have a JSF 2 application that contains a jar file, which in turn contains a faces-config.xml file in its META-INF directory. Face-config.xml contains a phase listener declaration. I would like to prevent the installation of this phase listener without modifying the jar file itself. Is it possible?

+6
source share
1 answer

You cannot block certain parts of faces-config.xml in a third-party JAR from interpretation.

You have basically 2 options:

  • Block all faces-config.xml in a third-party JAR from interpretation by adding metadata-complete="true" to webapp own faces-config.xml .

     <faces-config ... metadata-complete="true"> 

    Note that this also skips annotation scanning in third-party JAR classes. You basically need to override the specific parts that you would like to use in your own faces-config.xml web application.


  • Provide the Lifecycle LifecycleFactory that you registered with <factory><lifecycle-factory> for webapp faces-config.xml . In this implementation, override addPhaseListener() accordingly for execution, for example. a instanceof before skipping or continuing.

+4
source

All Articles