コード例 #1
0
ファイル: DoUpTreeTag.java プロジェクト: pgistgrp/pgtaglib
  protected void setProperties(UIComponent component) {

    super.setProperties(component);
    FacesContext context = FacesContext.getCurrentInstance();
    UIAction cmpt = (UIAction) component;

    if (styleClass != null) {
      if (isValueReference(styleClass)) {
        ValueBinding vb = context.getApplication().createValueBinding(styleClass);
        component.setValueBinding("styleClass", vb);
      } else {
        component.getAttributes().put("styleClass", styleClass);
      }
    }

    if (actionListener != null) {
      if (UIComponentTag.isValueReference(actionListener)) {
        Class args[] = {ActionEvent.class};
        MethodBinding vb =
            FacesContext.getCurrentInstance()
                .getApplication()
                .createMethodBinding(actionListener, args);
        cmpt.setActionListener(vb);
      } else {
        Object params[] = {actionListener};
        throw new FacesException(
            Util.getExceptionMessageString("com.sun.faces.INVALID_EXPRESSION", params));
      }
    }
  } // setProperties()
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
  public void decode(FacesContext context) {
    String curPage = null;
    String action = null;
    int actionInt = 0;
    int currentPage = 1;
    int currentRow = 1;
    String clientId = getClientId(context);
    Map requestParameterMap = (Map) context.getExternalContext().getRequestParameterMap();
    action = (String) requestParameterMap.get(clientId + "_action");
    if (action.equals("")) {
      action = lastAction;
    }
    MethodBinding mb = null;
    if (UIComponentTag.isValueReference(action)) {
      mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(action, null);
    } else {
      mb = Util.createConstantMethodBinding(action);
    }
    this.getAttributes().put("action", mb);
    lastAction = action;

    curPage = (String) requestParameterMap.get(clientId + "_curPage");
    if (!curPage.equals("")) {
      currentPage = Integer.valueOf(curPage).intValue();
    }

    // Assert that action's length is 1.
    switch (actionInt = Integer.valueOf(action).intValue()) {
      case ACTION_NEXT:
        currentPage++;
        break;
      case ACTION_PREVIOUS:
        // Assert 1 < currentPage
        if (currentPage > 1) {
          currentPage--;
        }
        break;
      default:
        currentPage = actionInt;
        break;
    }
    // from the currentPage, calculate the current row to scroll to.
    currentRow = (currentPage - 1) * getRowsPerPage(context);
    this.getAttributes().put("currentPage", new Integer(currentPage));
    this.getAttributes().put("currentRow", new Integer(currentRow));

    if (action == null || action.length() == 0) {
      // nothing to decode
      return;
    } else {
      this.queueEvent(new ActionEvent(this));
    }
  }
コード例 #4
0
 public static void setString(UIComponent component, String attributeName, String attributeValue) {
   if (attributeValue == null) return;
   if (UIComponentTag.isValueReference(attributeValue))
     setValueBinding(component, attributeName, attributeValue);
   else component.getAttributes().put(attributeName, attributeValue);
 }