Question

I have been using a Phase Listener to debug my JSF application.

Now I'm wondering if it's possible to load it dynamically depending on, for example, a system property is set or not (so I can commit the thing, and not worry about having to remove it before deploy in production). Does anyone know if there is a way to do that in faces-config.xml?

Thanks in advance!

Was it helpful?

Solution

You can add phaselisteners dynamically by UIViewRoot#addPhaseListener().

PhaseListener phaseListener = new YourPhaseListener();
FacesContext.getCurrentInstance().getViewRoot().addPhaseListener(phaseListener);

You've only to do it on a per-view basis. It's perhaps better to keep the phase listener registered and let it take actions only when the desired system property is set or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top