/**
   * <span class="changed_modified_2_0">Construct<span class="changed_modified_2_0"> a {@link
   * ValueChangeListener} that contains a {@link MethodExpression}. <span
   * class="changed_added_2_0">To accomodate method expression targets that take no arguments
   * instead of taking an {@link ActionEvent} argument</span>, the implementation of this class must
   * take the argument <code>methodExpressionOneArg</code>, extract its expression string, and
   * create another <code>MethodExpression</code> whose expected param types match those of a zero
   * argument method. The usage requirements for both of these <code>MethodExpression</code>
   * instances are described in {@link #processAction}.</span></span>
   *
   * @param methodExpressionOneArg a <code>MethodExpression</code> that points to a method that
   *     returns <code>void</code> and takes a single argument of type {@link ActionEvent}.
   */
  public MethodExpressionActionListener(MethodExpression methodExpressionOneArg) {

    super();
    this.methodExpressionOneArg = methodExpressionOneArg;
    FacesContext context = FacesContext.getCurrentInstance();
    ELContext elContext = context.getELContext();
    this.methodExpressionZeroArg =
        context
            .getApplication()
            .getExpressionFactory()
            .createMethodExpression(
                elContext,
                methodExpressionOneArg.getExpressionString(),
                Void.class,
                ACTION_LISTENER_ZEROARG_SIG);
  }
示例#2
0
 /**
  * Notify afterPhase listener that is registered on the View Root.
  *
  * @param context the FacesContext for the current request
  * @param lifecycle lifecycle instance
  */
 private void notifyAfter(FacesContext context, Lifecycle lifecycle) {
   UIViewRoot viewRoot = context.getViewRoot();
   MethodExpression afterPhase = viewRoot.getAfterPhaseListener();
   if (null != afterPhase) {
     try {
       PhaseEvent event = new PhaseEvent(context, PhaseId.RESTORE_VIEW, lifecycle);
       afterPhase.invoke(context.getELContext(), new Object[] {event});
     } catch (Exception e) {
       if (LOGGER.isLoggable(Level.SEVERE)) {
         LOGGER.log(
             Level.SEVERE,
             "severe.component.unable_to_process_expression",
             new Object[] {afterPhase.getExpressionString(), ("afterPhase")});
       }
       return;
     }
   }
 }