コード例 #1
0
  /**
   * return such window geometrical features as the height, width, top, left, scrollbars, and
   * resizable
   */
  protected String getWindowGeometry() {
    StringBuffer geometry = new StringBuffer();

    // determine the height and width of the wizard window
    Integer h = (Integer) theModel.getValue(theModel.WINDOW_HEIGHT);
    Integer w = (Integer) theModel.getValue(theModel.WINDOW_WIDTH);

    int height = h == null ? theModel.PIXEL_WINDOW_HEIGHT : h.intValue();
    int width = w == null ? theModel.PIXEL_WINDOW_WIDTH : w.intValue();

    // if using netscape 4 as client enable scrollbars
    String useScrollBars = isNav4() ? "yes" : "no";

    geometry
        .append("height=")
        .append(height)
        .append(", width=")
        .append(width)
        .append(", top='+((screen.height-(screen.height/1.618))-(")
        .append(height)
        .append("/2))+'")
        .append(", left='+((screen.width-")
        .append(width)
        .append(")/2)+'")
        .append("scrollbars=")
        .append(useScrollBars)
        .append(",resizable");

    return geometry.toString();
  }
コード例 #2
0
  /**
   * returns CCWizardWindowModelInterface instance parameters in the form of of name value i.e.
   * pageName=xyz
   */
  protected String getDefaultWizardParameters() {
    StringBuffer buffer = new StringBuffer();

    // remember the form name
    theModel.setValue(theModel.WIZARD_BUTTON_FORM, getFormName());

    // add the popup parameter
    theModel.setValue(POPUP_WINDOW, "true");

    String params = theModel.toRequestParametersString(WizardWindowViewBean.PAGE_NAME);
    buffer.append(encodeParams(params));

    String extraParams = theModel.toExtraRequestParameters();
    buffer.append(encodeParams(extraParams));

    // for 2.0.2 compatibility
    theModel.setValue(PASS_PAGE_SESSION, new Boolean(true));

    // append the JATO page session is appropriate
    Boolean appendPageSession = (Boolean) theModel.getValue(PASS_PAGE_SESSION);
    if (appendPageSession != null && appendPageSession.booleanValue()) {
      buffer
          .append(WizardWindowViewBean.PAGE_NAME)
          .append(".")
          .append(WizardWindowViewBean.CHILD_CMD_FIELD)
          .append("=")
          .append("&")
          .append(ViewBean.PAGE_SESSION_ATTRIBUTE_NVP_NAME)
          .append("=");
      String pageSessionString =
          ((ViewBean) theView.getParentViewBean()).getPageSessionAttributeString(false);
      buffer.append(pageSessionString);
    }

    return buffer.toString();
  }
コード例 #3
0
  /** this is the main method that generates the tag's HTML output */
  public String getHTMLStringInternal(Tag parent, PageContext pageContext, View view)
      throws JspException {
    // make sure all the parameters are valid
    String msg = null;
    if (parent == null) {
      msg = "Tag parameter is null";
      CCDebug.trace1(msg);
      throw new IllegalArgumentException(msg);
    } else if (pageContext == null) {
      msg = "PageContext parameter is null";
      CCDebug.trace1(msg);
      throw new IllegalArgumentException(msg);
    } else if (view == null) {
      msg = "View parameter is null";
      CCDebug.trace1(msg);
      throw new IllegalArgumentException(msg);
    }

    // verify is that the view passed is of the right type
    checkChildType(view, CCWizardWindow.class);
    theView = (CCWizardWindow) view;
    theModel = (CCWizardWindowModelInterface) theView.getModel();

    // init tag
    setParent(parent);
    setPageContext(pageContext);
    setAttributes();

    // holds the response string
    StringBuffer buffer = new StringBuffer();

    // check for the client-side javascript method to be called to set
    // the client-side parameters. - default to 'getClientParams()'
    String jsMethod = (String) theModel.getValue(CLIENTSIDE_PARAM_JSFUNCTION);
    if (jsMethod == null) jsMethod = "getClientParams";

    // retrieve the various parts of the 'window.open(...)' call
    String url = getWizardURL();
    String defaultParameters = getDefaultWizardParameters();
    String windowGeometry = getWindowGeometry();
    String windowName =
        (new StringBuffer(WINDOW_NAME)).append("_").append(HtmlUtil.getUniqueValue()).toString();

    // Set the Onclick attribute
    StringBuffer onClick = new StringBuffer();
    onClick
        .append("javascript: var url='")
        .append(url)
        .append("'; var defaultParams='")
        .append(defaultParameters)
        .append("'; var geometry='")
        .append(windowGeometry)
        .append("'; var windowName='")
        .append(windowName)
        .append("'; alert('windowName:  ' + windowName); var csParams=")
        .append(jsMethod)
        .append("(); alert('csParams:  ' + csParams); ")
        .append("var fullURL = url; if (csParams != null) {")
        .append(" fullURL += csParams + '&';}")
        .append(" fullURL += defaultParams;")
        .append(" alert('hi2'); ")
        .append("var win = window.open(fullURL, windowName, geometry);")
        .append("win.focus();alert('hi3'); return true;");
    // launchWizard(url, defaultParams,")
    // .append(" csParams, windowName, geometry);")

    setOnClick(onClick.toString());

    // the tags payload
    buffer
        .append("\n<!-- Start Wizard Tag -->\n")
        .append(super.getHTMLStringInternal(parent, pageContext, theView))
        .append("\n<!-- End Wizard Tag -->\n");

    return buffer.toString();
  }