Edit: I should point out that BalusC's answer should probably be the preferred way to solve this problem. But if you still want to play with phase order, keep reading. /end-edit
Actually the phaseListeners may be invoked both before and after your method specified in action-attribute, if you implement it to Listen to every phase.
public class MyPhaseListener implements PhaseListener {
public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; }
public void beforePhase(PhaseEvent event) {
System.out.println("Before Phase: " + event.getPhaseId());
}
public void afterPhase(PhaseEvent event) {
System.out.println("After Phase: " + event.getPhaseId());
}
}
activate your Listener in faces-config.xml
<faces-config ... >
<lifecycle>
<phase-listener>MyPhaseListener</phase-listener>
</lifecycle>
</faces-config>
Here is the printout of all Listener invokations and when actionListener and action is invoked:
INFO: Before Phase: RESTORE_VIEW 1
INFO: After Phase: RESTORE_VIEW 1
INFO: Before Phase: APPLY_REQUEST_VALUES 2
INFO: After Phase: APPLY_REQUEST_VALUES 2
INFO: Before Phase: PROCESS_VALIDATIONS 3
INFO: After Phase: PROCESS_VALIDATIONS 3
INFO: Before Phase: UPDATE_MODEL_VALUES 4
INFO: After Phase: UPDATE_MODEL_VALUES 4
INFO: Before Phase: INVOKE_APPLICATION 5
INFO: ActionListener Done
INFO: Action Done
INFO: After Phase: INVOKE_APPLICATION 5
INFO: Before Phase: RENDER_RESPONSE 6
INFO: After Phase: RENDER_RESPONSE 6