How can I implement a PhaseListener
which runs at end of the JSF lifecycle?
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- Infinite setStatus() loop when requesting a JSF pa
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
相关文章
- How to allow numbers only using f:validateRegex
- JSF 2.0: ajax request when press ENTER
- Formatting a double in JSF
- change rendered attribute from managed bean
- How to show confirm (richfaces) popup when
- How to override primefaces component api class wit
- JPA lazy loading Collections in JSF view - better
- How to design a session-less JSF 2.0 web applicati
In
jsf 2
you can use<f:phaseListener type="my.MyPhaseListener">
to hookMyPhaseListener
for somefacelet
.MyPhaseListener
should implementPhaseListener
and overrideafterPhase
- with code to be run after end of phasebeforePhase
- with code to be run before phase startedgetPhaseId
-PhaseId
enum specifying name of phase for which the listener to be invoked (PhaseId.RENDER_RESPONSE
as last phase of lifecycle)You need to implement the
PhaseListener
interface and hook onbeforePhase()
of thePhaseId_RENDER_RESPONSE
. The render response is the last phase of the JSF lifecycle.To get it to run, register it as follows in
faces-config.xml
:Update the above phase listener is indeed applicaiton-wide. To have a phase listener for a specific view, use the
beforePhase
and/orafterPhase
attributes of the<f:view>
.E.g.
with
A more JSF 2.0 way is by the way using the
<f:event type="preRenderView">
:with