Package org.richfaces.component

Examples of org.richfaces.component.DialogContext


  public String getOnClick(FacesContext context, UIComponent component) {
    if (getUtils().isBooleanAttribute(component, "disabled")) {
      return "return false;";
    }
    DialogContext dcontext = DialogContextManager.getInstance(context).getActiveContext();

    StringBuffer superOnClick = null;
    if(UIDialogAction.isServerMode(component)) {
      String formId = DialogWindowUtils.findAncestorForm(context, component);
View Full Code Here


     * Parameter action=close is set by js function closeDialog()
     * for AJAX request simulating this action.
     */
    String action = (String)context.getExternalContext().getRequestParameterMap().get("action");
   
    DialogContext dcontext = DialogContextManager.getInstance(context).getContext(dialogId);

    String posReferenceId = (String)context.getExternalContext().getRequestParameterMap().get("posReferenceId");
    ((UIDialogWindow)component).setPosExternalReferenceId(posReferenceId);

    ActionSource actionSource = (ActionSource) component;

    /*
     * Specific navigation for open/close dialogs
     * includes prefixes to outcomes. We need to
     * intercept computed outcome to extract the prefix
     * and provide JSF with outcome stripped of it.
     */
        MethodBinding binding = actionSource.getAction();
        if(!(binding instanceof DialogMethodBinding)) {
          actionSource.setAction(new DialogMethodBinding(binding, (ActionPrefixHolder)component));
        }
       
        DialogOpenEvent dialogEvent = new DialogOpenEvent(component);
       
    if(!"close".equals(action) && !"closeall".equals(action)) {
     
      /*
       * Button has been pressed.
       * Child dialog is to be open.
       * We need to send a standard ActionEvent to
       * let JSF to pass all the lifecycle up to
       * the end of invoke application phase where
       * we will interfere and change the navigation logic.
       */
      DialogContext parentContext = DialogContextManager.getInstance(context).getActiveContext();
      DialogContextManager.getInstance(context).setActiveRequest(dialogId);
      if(parentContext != null && parentContext != dcontext) parentContext.addChildContext(dcontext);
      dcontext.setLocked(false);

      Object type = component.getAttributes().get("type");
         if (null == type || ! "reset".equalsIgnoreCase((String)type) ) {
///           String mode = ((UIDialogAction)component).getMode();
           ActionEvent event;
           event = new ActionEvent(component);
           component.queueEvent(event);
           if(component instanceof ViewIdHolder) {
             component.queueEvent( new AjaxEvent(component));
//             ((UIDialogWindow)component).initViewId();
//             AjaxContext.getCurrentInstance(context).setViewIdHolder((ViewIdHolder)component);
//             return;
           }

         } else {
         component.queueEvent( new AjaxEvent(component));
       }
    } else {
      /*
       * Child dialog has just been closed.
       * It simulates action of this component
       * by AJAX request from js function closeDialog()
       * Parameter 'targetViewId' is id of view
       * that would be shown in dialog window if it had not
       * to be closed. Now it is saved in event
       * to be substituted for view root of this window.
       */
      String targetViewId = (String)context.getExternalContext().getRequestParameterMap().get("targetViewId");
      if(targetViewId != null) {
        dialogEvent.setSourceViewId(targetViewId);
      }
      DialogContext parentContext = dcontext.getParentContext();
      dcontext.deactivate();
          if(parentContext != null) {
        DialogContextManager.getInstance(context).setActiveRequest(parentContext.getDialogId());
          } else if("closeall".equals(action)) {
          DialogContextManager.getInstance(context).setActiveRequest(null);
      } else {
          DialogContextManager.getInstance(context).setActiveRequest(null);
      }
View Full Code Here

    }
    return sb.toString();
  }
 
  public String getDialogBox(FacesContext context, UIComponent component) throws IOException {
        DialogContext dcontext = DialogContextManager.getInstance(context).getContext(component.getClientId(context));
    String dialogPath = DialogWindowUtils.getDialogPath(context, component);
    if(dialogPath == null) return "";
    String dialogId = component.getClientId(context);
    // Added by Hans, Wed Mar  7 14:55:24 EET 2007, CH-1541
    StringBuffer options = new StringBuffer(DialogWindowUtils.getOptions(context, component, getUtils()));
View Full Code Here

      Object  value = paramMap.get( clientId );
    return null != value;
  }
 
  public String getParentDialogId(DialogContext dcontext) {
    DialogContext parentContext = dcontext.getParentContext();
    return (parentContext == null) ? null : "'" + parentContext.getDialogId() + "'";
  }
View Full Code Here

  public static String getRunCondition() {
    return "try {if(window.hasModalDialog) return false;this.onclick='';this.click=null; window.hasModalDialog=true;} catch (e) {'error in runCondition: ' + e.message};";
  }
 
  public static String getDialogPath(FacesContext context, UIComponent component) {
        DialogContext dcontext = DialogContextManager.getInstance(context).getContext(component.getClientId(context));
    return dcontext.getDialogPath();
  }
View Full Code Here

  }

  public static void saveParameters(UIComponent uiComponent, FacesContext facesContext) {
    if(!(uiComponent instanceof UIDialogWindow)) return;
    String dialogId = uiComponent.getClientId(facesContext);
    DialogContext context = DialogContextManager.getInstance(facesContext).getContext(dialogId);
    for (Iterator it = uiComponent.getChildren().iterator(); it.hasNext();) {
      UIComponent child = (UIComponent) it.next();
      if (child instanceof UIParameter) {
        String name = ((UIParameter) child).getName();
        Object value = ((UIParameter) child).getValue();
        if (null == name) {
          throw new IllegalArgumentException(Messages.getMessage(
              Messages.UNNAMED_PARAMETER_ERROR, uiComponent
                  .getClientId(facesContext)));
        }
        boolean escape = true;
        if (child instanceof JavaScriptParameter) {
          JavaScriptParameter actionParam = (JavaScriptParameter) child;
          escape = !actionParam.isNoEscape();
        }
        if (escape) {
          context.setParameter(name, value);
        } else {
//          parameters.put(name, new JSReference(value.toString()));
        }
      }
    }
View Full Code Here

    if(!isSubmitted(getUtils(), context, component)) {
      return;
    }
    String dialogId = component.getClientId(context);
    String action = (String)context.getExternalContext().getRequestParameterMap().get("action");
    DialogContext dcontext = DialogContextManager.getInstance(context).getContext(dialogId);
        DialogOpenEvent dialogEvent = new DialogOpenEvent(component);
       
    if(!"close".equals(action) && !"closeall".equals(action)) {
      DialogContext parentContext = DialogContextManager.getInstance(context).getActiveContext();
      DialogContextManager.getInstance(context).setActiveRequest(dialogId);
      if(parentContext != null && parentContext != dcontext) parentContext.addChildContext(dcontext);
      dcontext.setLocked(false);
      ViewHandler vh = UIDialogAction.getViewHandler(context);
      String targetActionURL = (String)((UIDialogWindow)component).getValue();
      targetActionURL = vh.getActionURL(context, targetActionURL);
          dcontext.setDialogPath(targetActionURL);
       component.queueEvent( new AjaxEvent(component));
       context.renderResponse();
    } else {
      String targetViewId = (String)context.getExternalContext().getRequestParameterMap().get("targetViewId");
      if(targetViewId != null) {
        dialogEvent.setSourceViewId(targetViewId);
      }
      DialogContext parentContext = dcontext.getParentContext();
      dcontext.deactivate();
          if(parentContext != null) {
        DialogContextManager.getInstance(context).setActiveRequest(parentContext.getDialogId());
          } else if("closeall".equals(action)) {
          DialogContextManager.getInstance(context).setActiveRequest(null);
      } else {
          DialogContextManager.getInstance(context).setActiveRequest(null);
      }
View Full Code Here

TOP

Related Classes of org.richfaces.component.DialogContext

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.