Problems with facelets and beforePhaseListener and f:phaseListener  XML
Forum Index -> General Help
Author Message

Joined: 01/Feb/2008 00:00:00
Messages: 42

I think that thera are some problems with applications using jsf1.2and icefaces-facelets if beforePhaseListener or f:phaseListener used .

Test case
- add to file com.sun.facelets.tag.jsf.core.ViewHandler and methods ViewHandler and apply two
println's as :
System.out.println("Facelets ViewHandler constructor this.beforePhaseListener:"+this.beforePhaseListener+"|");
System.out.println("Facelets ViewHandler apply this.beforePhaseListener:"+this.beforePhaseListener+"|");

- to view add
<f:view beforePhaseListener="#{test.beforePhase}"
<f:phaseListener binding="#{test}"/>

- to bean class add
public void beforePhase(PhaseEvent event) {
log.debug("beforePhase called phaseid:" + event.getPhaseId() + " source:" + event.getSource());
public void afterPhase(PhaseEvent event) {
log.debug("afterPhase called phaseid:" + event.getPhaseId() + " source:" + event.getSource());

- beforePhaseListener are never called on bean or view init - if view is not visible yet
- beforePhaseListener are called multiple times on rowselector row change (for datatable) or menu submit
- f:phaseListener without before/afterPhaseListener do nothing, only getPhaseId is called

Current behaviour of BeforePhaseListener is probably useless for data initialization, f:phaseListener is also useless

Similar results are discussed here

Krashan Brahmanjara

Joined: 27/Nov/2006 00:00:00
Messages: 332

I met the same problem. I have this SearchController which returns some results, and the dataTable holding the results should be sortable according to different criteria.
One of the "wrong" things is that the "action" methods on the command sort headers are called before the backing bean gets the selected column and the ascending/descending flag set. The workaround is to make a Phase Listener and resort the results depending on the current flags.
Of course I met the same behavior when trying to use the f:phaseListener (it's not called on the first display of the page and also never for APPLY_REQEST_VALUES and RENDER_RESPONSE) and I did a workaround using the standard PhaseListener approach (registered in faces-config). Then it occurred to me that I shoul give it another try and I made an init method annotated with @PostConstruct where I manually add "this" (being the controller) to getFacesContext().getViewRoot()'s phase listeners. And guess what?
It doesn't work. It has the same stupid behavior like f:phaseListener.
So I'll stick to the faces-config phaselistener for now ... trying to minimize the evil.
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team