Skip to content

Commit

Permalink
Fixes #75 - Add ability to add PhaseListeners to AjaxLifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Automated workflow committed Nov 27, 2023
1 parent 84c3ab4 commit 4ff1e97
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -32,6 +32,7 @@
import jakarta.faces.event.PhaseListener;
import jakarta.faces.lifecycle.Lifecycle;
import jakarta.inject.Named;
import java.util.ArrayList;

/**
* The AJAX lifecycle.
Expand All @@ -42,6 +43,11 @@
@Named("com.manorrock.oyena.lifecycle.ajax.AjaxLifecycle")
public class AjaxLifecycle extends Lifecycle {

/**
* Stores the phase listeners.
*/
private ArrayList<PhaseListener> phaseListeners = new ArrayList<>();

/**
* Constructor.
*/
Expand All @@ -60,7 +66,7 @@ public AjaxLifecycle() {
*/
@Override
public void addPhaseListener(PhaseListener phaseListener) {
// phase listeners are not supported.
phaseListeners.add(phaseListener);
}

/**
Expand All @@ -76,16 +82,11 @@ public void execute(FacesContext facesContext) throws FacesException {
/**
* Get the phase listeners.
*
* <p>
* As phase listeners are not supported by the Action lifecycle this will
* always return a zero length array.
* </p>
*
* @return the empty array of phase listeners.
*/
@Override
public PhaseListener[] getPhaseListeners() {
return new PhaseListener[0];
return (PhaseListener[]) phaseListeners.toArray();
}

/**
Expand All @@ -99,7 +100,7 @@ public PhaseListener[] getPhaseListeners() {
*/
@Override
public void removePhaseListener(PhaseListener phaseListener) {
// phase listeners are not supported.
phaseListeners.remove(phaseListener);
}

/**
Expand Down

0 comments on commit 4ff1e97

Please sign in to comment.