org.richfaces.event

## Class MethodExpressionEventListener

- java.lang.Object
- - org.richfaces.event.MethodExpressionEventListener

- All Implemented Interfaces:
    EventListener, javax.faces.component.StateHolder, javax.faces.event.FacesListener
  Direct Known Subclasses:
    FileUploadHandler.FileUploadListenerImpl, MethodExpressionItemChangeListener, MethodExpressionPanelToggleListener, MethodExpressionTreeSelectionChangeListener, MethodExpressionTreeToggleListener

      public abstract class MethodExpressionEventListener
      extends Object
      implements javax.faces.event.FacesListener, javax.faces.component.StateHolder

  MethodExpressionEventListener is a `FacesListener` that wraps a `MethodExpression`. When it receives a `FacesEvent`, it executes a method on an object identified by the `MethodExpression`.

  Version:
    1.0
  Author:
    akolonitsky

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `MethodExpressionEventListener()`
    `protected` | `MethodExpressionEventListener(javax.el.MethodExpression methodExpressionOneArg)` Construct a `FacesListener` that contains a `MethodExpression` .To accomodate method expression targets that take no arguments instead of taking a `FacesEvent` argument, the implementation of this class must take the argument `methodExpressionOneArg`, extract its expression string, and create another `MethodExpression` whose expected param types match those of a zero argument method.
    `protected` | `MethodExpressionEventListener(javax.el.MethodExpression methodExprOneArg, javax.el.MethodExpression methodExprZeroArg)` Construct a `FacesListener` that contains a `MethodExpression`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isTransient()`
    `void` | `processEvent(javax.faces.event.FacesEvent event)` Call through to the `MethodExpression` passed in our constructor.
    `void` | `restoreState(javax.faces.context.FacesContext context, Object state)` Both `MethodExpression` instances described in the constructor must be restored.
    `Object` | `saveState(javax.faces.context.FacesContext context)` Both `MethodExpression` instances described in the constructor must be saved.
    `void` | `setTransient(boolean newTransientValue)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MethodExpressionEventListener

          protected MethodExpressionEventListener()

    - #### MethodExpressionEventListener

          protected MethodExpressionEventListener(javax.el.MethodExpression methodExpressionOneArg)

      Construct a `FacesListener` that contains a `MethodExpression` .To accomodate method expression targets that take no arguments instead of taking a `FacesEvent` argument, the implementation of this class must take the argument `methodExpressionOneArg`, extract its expression string, and create another `MethodExpression` whose expected param types match those of a zero argument method. The usage requirements for both of these `MethodExpression` instances are described in `processEvent(javax.faces.event.FacesEvent)`.

      Parameters:
        `methodExpressionOneArg` - a `MethodExpression` that points to a method that returns `void` and takes a single argument of type `FacesEvent`.

    - #### MethodExpressionEventListener

          protected MethodExpressionEventListener(javax.el.MethodExpression methodExprOneArg,
                                       javax.el.MethodExpression methodExprZeroArg)

      Construct a `FacesListener` that contains a `MethodExpression`.

      Parameters:
        `methodExprOneArg` -
        `methodExprZeroArg` -

  - ### Method Detail

    - #### processEvent

          public void processEvent(javax.faces.event.FacesEvent event)
                            throws javax.faces.event.AbortProcessingException

      Call through to the `MethodExpression` passed in our constructor. First, try to invoke the `MethodExpression` passed to the constructor of this instance, passing the argument `FacesEvent` as the argument. If a `MethodNotFoundException` is thrown, call to the zero argument `MethodExpression` derived from the `MethodExpression` passed to the constructor of this instance. If that fails for any reason, throw an `AbortProcessingException`, including the cause of the failure.

      Throws:
        `NullPointerException`
        `javax.faces.event.AbortProcessingException`

    - #### saveState

          public Object saveState(javax.faces.context.FacesContext context)

      Both `MethodExpression` instances described in the constructor must be saved.

      Specified by:
        `saveState` in interface `javax.faces.component.StateHolder`

    - #### restoreState

          public void restoreState(javax.faces.context.FacesContext context,
                          Object state)

      Both `MethodExpression` instances described in the constructor must be restored.

      Specified by:
        `restoreState` in interface `javax.faces.component.StateHolder`

    - #### isTransient

          public boolean isTransient()

      Specified by:
        `isTransient` in interface `javax.faces.component.StateHolder`

    - #### setTransient

          public void setTransient(boolean newTransientValue)

      Specified by:
        `setTransient` in interface `javax.faces.component.StateHolder`

Copyright © 2014 JBoss by Red Hat. All Rights Reserved.