Package javax.faces.event

Examples of javax.faces.event.PhaseListener


    private void informPhaseListenersBefore(FacesContext facesContext, PhaseId phaseId)
    {
        PhaseListener[] phaseListeners = getPhaseListeners();
        for (int i = 0; i < phaseListeners.length; i++)
        {
            PhaseListener phaseListener = phaseListeners[i];
            int listenerPhaseId = phaseListener.getPhaseId().getOrdinal();
            if (listenerPhaseId == PhaseId.ANY_PHASE.getOrdinal() ||
                listenerPhaseId == phaseId.getOrdinal())
            {
                phaseListener.beforePhase(new PhaseEvent(facesContext, phaseId, this));
            }
        }

    }
View Full Code Here


    private void informPhaseListenersAfter(FacesContext facesContext, PhaseId phaseId)
    {
        PhaseListener[] phaseListeners = getPhaseListeners();
        for (int i = 0; i < phaseListeners.length; i++)
        {
            PhaseListener phaseListener = phaseListeners[i];
            int listenerPhaseId = phaseListener.getPhaseId().getOrdinal();
            if (listenerPhaseId == PhaseId.ANY_PHASE.getOrdinal() ||
                listenerPhaseId == phaseId.getOrdinal())
            {
                phaseListener.afterPhase(new PhaseEvent(facesContext, phaseId, this));
            }
        }

    }
View Full Code Here

        PhaseEvent event = new PhaseEvent(facesContext, phaseId, lifecycle);

        for (int i = 0; i < phaseListeners.length; i++)
        {
            PhaseListener phaseListener = phaseListeners[i];
            if (isListenerForThisPhase(phaseListener, phaseId))
            {
                try
                {
                    phaseListener.beforePhase(event);
                    beforePhaseSuccess[i] = true;
                }
                catch (Throwable e)
                {
                    beforePhaseSuccess[i] = false; // redundant - for clarity
View Full Code Here

        PhaseEvent event = null;

        for (int i = phaseListeners.length - 1; i >= 0; i--)
        {
            PhaseListener phaseListener = phaseListeners[i];
            if (isListenerForThisPhase(phaseListener, phaseId) && beforePhaseSuccess[i])
            {
                if (event == null)
                {
                    event = new PhaseEvent(facesContext, phaseId, lifecycle);
                }
                try
                {
                    phaseListener.afterPhase(event);
                }
                catch (Throwable e)
                {
                    // JSF 2.0: publish exceptions instead of logging them.
                   
View Full Code Here

                if (beforePhase)
                {
                    // process listeners in ascending order
                    for (int i = 0; i < beforePhaseSuccess.length - 1; i++)
                    {
                        PhaseListener phaseListener;
                        try
                        {
                            phaseListener = phaseListeners.get(i);
                        }
                        catch (IndexOutOfBoundsException e)
                        {
                            // happens when a PhaseListener removes another PhaseListener
                            // from UIViewRoot in its beforePhase method
                            throw new IllegalStateException("A PhaseListener must not remove " +
                                    "PhaseListeners from UIViewRoot.");
                        }
                        PhaseId listenerPhaseId = phaseListener.getPhaseId();
                        if (phaseId.equals(listenerPhaseId) || PhaseId.ANY_PHASE.equals(listenerPhaseId))
                        {
                            try
                            {
                                phaseListener.beforePhase(event);
                                beforePhaseSuccess[i + 1] = true;
                            }
                            catch (Throwable t)
                            {
                                beforePhaseSuccess[i + 1] = false; // redundant - for clarity
                                logger.log(Level.SEVERE, "An Exception occured while processing the " +
                                                         "beforePhase method of PhaseListener " + phaseListener +
                                                         " in Phase " + phaseId, t);
                                return context.getResponseComplete() ||
                                        (context.getRenderResponse() && !PhaseId.RENDER_RESPONSE.equals(phaseId));
                            }
                        }
                    }
                }
                else
                {
                    // afterPhase
                    // process listeners in descending order
                    for (int i = beforePhaseSuccess.length - 1; i > 0; i--)
                    {
                        PhaseListener phaseListener;
                        try
                        {
                            phaseListener = phaseListeners.get(i - 1);
                        }
                        catch (IndexOutOfBoundsException e)
                        {
                            // happens when a PhaseListener removes another PhaseListener
                            // from UIViewRoot in its beforePhase or afterPhase method
                            throw new IllegalStateException("A PhaseListener must not remove " +
                                    "PhaseListeners from UIViewRoot.");
                        }
                        PhaseId listenerPhaseId = phaseListener.getPhaseId();
                        if ((phaseId.equals(listenerPhaseId) || PhaseId.ANY_PHASE.equals(listenerPhaseId))
                                && beforePhaseSuccess[i])
                        {
                            try
                            {
                                phaseListener.afterPhase(event);
                            }
                            catch (Throwable t)
                            {
                                logger.log(Level.SEVERE, "An Exception occured while processing the " +
                                                         "afterPhase method of PhaseListener " + phaseListener +
View Full Code Here

        //call the listeners in reverse-order (like jsf)
        ListIterator<PhaseListener> phaseListenerIterator = this.phaseListeners.listIterator(phaseListeners.size());

        while (phaseListenerIterator.hasPrevious())
        {
            PhaseListener phaseListener = phaseListenerIterator.previous();
            PhaseId targetPhase = phaseListener.getPhaseId();

            if (targetPhase == PhaseId.ANY_PHASE || targetPhase == phaseEvent.getPhaseId())
            {
                phaseListener.afterPhase(phaseEvent);
            }
        }
    }
View Full Code Here

        // add the HttpMethodRestrictionPhaseListener if the parameter is enabled.
        boolean enabled = this.isOptionEnabled(BooleanWebContextInitParameter.EnableHttpMethodRestrictionPhaseListener);
        if (enabled) {
            LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
            Iterator<String> ids = factory.getLifecycleIds();
            PhaseListener listener = null;
            Lifecycle cur;

            while (ids.hasNext()) {
                cur = factory.getLifecycle(ids.next());
                boolean foundExistingListenerInstance = false;
View Full Code Here

  private void processPhaseListeners(PhaseListener[] phaseListeners,
      PhaseEvent phaseEvent, boolean beforePhase) {
    if (beforePhase) {
      // Invoke before phase listeners
      for (int i = 0; i < phaseListeners.length; i++) {
        PhaseListener phaseListener = phaseListeners[i];
        invokePhaseListener(phaseListener, phaseEvent, beforePhase);
      }

    } else {
      // Invoke after phase listeners, in reverse order.
      for (int i = phaseListeners.length - 1; i >= 0; i--) {
        PhaseListener phaseListener = phaseListeners[i];
        invokePhaseListener(phaseListener, phaseEvent, beforePhase);
      }

    }
  }
View Full Code Here

            ValueExpression b = null;
            if (this.binding != null) {
                b = this.binding.getValueExpression(ctx, PhaseListener.class);
            }

            PhaseListener pl = new LazyPhaseListener(this.listenerType, b);

            // special handling for UIViewRoot since ComponentHandler.isNew()
            // will always return true
            if (parent instanceof UIViewRoot) {
                List<PhaseListener> listeners = root.getPhaseListeners();
View Full Code Here

            }
            return instance;
        }

        public void afterPhase(PhaseEvent event) {
            PhaseListener pl = this.getInstance();
            if (pl != null) {
                pl.afterPhase(event);
            }
        }
View Full Code Here

TOP

Related Classes of javax.faces.event.PhaseListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.