/**
  * Returns the current option element's action.
  *
  * @return the current option element's action
  */
 public String nodeAction() {
   String id = getMenuModel().getSelectedNodeId();
   IMenuItem menuItem = (IMenuItem) getMenuModel().getMenuItem(id);
   String action = menuItem.getReference();
   if (UIComponentTag.isValueReference(action)) {
     FacesContext facesContext = FacesContext.getCurrentInstance();
     MethodBinding mb = facesContext.getApplication().createMethodBinding(action, null);
     action = (String) mb.invoke(facesContext, null);
   }
   LOGGER.fine("nodeAction: " + id + " action: " + action);
   return action;
 }
Exemplo n.º 2
0
  /**
   * In addition to to the default {@link UIComponent#broadcast} processing, pass the {@link
   * ValueChangeEvent} being broadcast to the method referenced by <code>valueChangeListener</code>
   * (if any).
   *
   * @param event {@link FacesEvent} to be broadcast
   * @exception AbortProcessingException Signal the JavaServer Faces implementation that no further
   *     processing on the current event should be performed
   * @exception IllegalArgumentException if the implementation class of this {@link FacesEvent} is
   *     not supported by this component
   * @exception NullPointerException if <code>event</code> is <code>null</code>
   */
  public void broadcast(FacesEvent event) throws AbortProcessingException {

    // Perform standard superclass processing
    super.broadcast(event);

    if (event instanceof ValueChangeEvent) {
      MethodBinding method = getValueChangeListener();
      if (method != null) {
        FacesContext context = getFacesContext();
        method.invoke(context, new Object[] {event});
      }
    }
  }
 public void renderView(FacesContext context, UIViewRoot viewRoot)
     throws IOException, FacesException {
   String viewId = viewRoot.getViewId();
   if (!context.getResponseComplete() && isMapped(viewId)) {
     NavigationHandler nh = context.getApplication().getNavigationHandler();
     ViewHandler vh = context.getApplication().getViewHandler();
     String action = (String) context.getExternalContext().getRequestParameterMap().get("action");
     String outcome =
         (String) context.getExternalContext().getRequestParameterMap().get("outcome");
     if (action != null) {
       String method = extractMethodName(action);
       MethodBinding mb =
           context.getApplication().createMethodBinding("#{" + action + "}", new Class[0]);
       outcome = mb.invoke(context, new Object[0]).toString();
       nh.handleNavigation(context, method, outcome);
       if (!context.getResponseComplete() && context.getViewRoot().equals(viewRoot)) {
         throw new FacesException(
             "No navigation rules from viewId="
                 + viewId
                 + ", action="
                 + action
                 + ", outcome="
                 + outcome
                 + " found.");
       }
     } else {
       nh.handleNavigation(context, null, outcome);
       if (!context.getResponseComplete() && context.getViewRoot().equals(viewRoot)) {
         throw new FacesException(
             "No navigation rules from viewId=" + viewId + ", outcome=" + outcome + " found.");
       }
     }
     if (!context.getResponseComplete()) {
       vh.renderView(context, context.getViewRoot());
     }
     ;
   } else {
     viewHandler.renderView(context, viewRoot);
   }
 }
Exemplo n.º 4
0
 public void validate(FacesContext context, UIComponent component, Object value)
     throws ValidatorException {
   if (null == context || null == component) {
     throw new NullPointerException();
   }
   try {
     methodBinding.invoke(context, new Object[] {context, component, value});
   } catch (EvaluationException ee) {
     Throwable cause = this.getExpectedCause(ValidatorException.class, ee);
     if (cause instanceof ValidatorException) {
       throw ((ValidatorException) cause);
     }
     if (cause instanceof RuntimeException) {
       throw ((RuntimeException) cause);
     }
     throw new IllegalStateException(ee);
   }
 }
Exemplo n.º 5
0
  public Object saveState(FacesContext context) {
    if (context == null) {
      throw new NullPointerException();
    }
    Object result = null;
    if (!tranzient) {
      if (methodBinding instanceof StateHolder) {
        Object[] stateStruct = new Object[2];

        // save the actual state of our wrapped methodBinding
        stateStruct[0] = ((StateHolder) methodBinding).saveState(context);
        // save the class name of the methodBinding impl
        stateStruct[1] = methodBinding.getClass().getName();

        result = stateStruct;
      } else {
        result = methodBinding;
      }
    }

    return result;
  }