示例#1
0
 private void processLocaleArray(
     String[] ar, String key, String appName, LanguagePreferences p, StringBuffer sb) {
   for (int i = 0; i < ar.length; i++) {
     sb.setLength(0);
     sb.append(key);
     sb.append(new Integer(i).toString());
     String val = LanguageResourceFinder.getResource(appName, sb.toString(), p);
     if (val != null) ar[i] = val;
   }
 }
示例#2
0
  private void processLocaleInfo() {
    if (_updateLocale) {
      _updateLocale = false;
      LanguagePreferences p = getPage().getLanguagePreferences();
      String appName = getPage().getApplicationName();
      StringBuffer key = new StringBuffer("HtmlCalendar.month.short.0");
      boolean shortOK = (LanguageResourceFinder.getResource(appName, key.toString(), p) != null);
      key.setLength(0);
      key.append("HtmlCalendar.month.long.0");
      boolean longOK = (LanguageResourceFinder.getResource(appName, key.toString(), p) != null);

      if (shortOK) {
        processLocaleArray(_monthShortNames, "HtmlCalendar.month.short.", appName, p, key);
        processLocaleArray(_dayShortNames, "HtmlCalendar.day.short.", appName, p, key);
      }

      if (longOK) {
        processLocaleArray(_monthLongNames, "HtmlCalendar.month.long.", appName, p, key);
        processLocaleArray(_dayLongNames, "HtmlCalendar.day.long.", appName, p, key);
      }
    }
  }
  private String generatePopupHtml(int row) {
    if (_showDescription && _editHandle instanceof HtmlTextEdit) {
      String rowNo = row == -1 ? "" : "_" + row;
      ((HtmlTextEdit) _editHandle)
          .setOnChange(
              "var theSpan=document.getElementById(\'div"
                  + getFullName()
                  + rowNo
                  + "'); if (theSpan) theSpan.innerHTML=''; "
                  + getHiddenDescrFieldFullName(row)
                  + ".value='';");
      // ((HtmlTextEdit) _editHandle).setHighlightOnFocus(_highlightOnFocus);
    }

    if (_usePopup) {
      if (_visible && _enabled) {
        StringBuffer jsPopupVars = new StringBuffer();

        if (_editHandle != null) {
          jsPopupVars.append("obj=");
          jsPopupVars.append(this.getFormString());
          jsPopupVars.append(((HtmlComponent) _editHandle).getFullName());
          jsPopupVars.append(((row == -1) ? "" : ("_" + row)));
          jsPopupVars.append(";");
        }

        String urlParms =
            PARAM_LOOKUP_CONTROLLER
                + "=$jsp$"
                + ((JspController) this.getPage()).getSessionKey()
                + "&"
                + PARAM_LOOKUP_COMPONENT
                + "="
                + this.getName()
                + "&"
                + PARAM_LOOKUP_ROW
                + "="
                + row;

        jsPopupVars.append("url='");
        String lookupPageURL = getLookUpPageURL();
        jsPopupVars.append(lookupPageURL);
        if (lookupPageURL != null && lookupPageURL.indexOf("?") == -1) jsPopupVars.append("?");
        else jsPopupVars.append("&");
        jsPopupVars.append(urlParms);
        jsPopupVars.append("&" + PARAM_LOOKUP_VALUE + "='+escape(obj.value)");
        // pass any values from other components on the page if
        // necessary
        if (_popupURLLineValues != null) {
          for (int i = 0; i < _popupURLLineValues.size(); i++) {
            FormComponentInfo inf = (FormComponentInfo) _popupURLLineValues.elementAt(i);
            jsPopupVars.append("+'&");
            jsPopupVars.append(inf.attName);
            jsPopupVars.append("='+escape(");
            jsPopupVars.append(inf.compName);
            if (inf.isInDataTable) jsPopupVars.append("_" + row);
            jsPopupVars.append(".value)");
          }
        }
        // add extra parms to the component
        if (_extraParms != null) jsPopupVars.append("+" + _extraParms);
        jsPopupVars.append(";");
        HtmlScriptGenerator gen = new HtmlScriptGenerator((JspController) getPage());
        if (_useDiv)
          jsPopupVars.append(
              gen.generatePopupDivScript(
                  "url",
                  getPopupPosition(),
                  getPopupTop(),
                  getPopupLeft(),
                  getPopupWidth(),
                  getPopupHeight(),
                  _useModal,
                  _divBorderStyle,
                  (_divScrolling ? "auto" : "no"),
                  (HtmlComponent) _editHandle,
                  row));
        else
          jsPopupVars.append(
              gen.generateOpenPopupScript(
                  "url",
                  getPopupPosition(),
                  getPopupTop(),
                  getPopupLeft(),
                  getPopupWidth(),
                  getPopupHeight(),
                  _useModal,
                  _popupAttributes,
                  (HtmlComponent) _editHandle,
                  row));

        _browsePopupImageLink.setHref("javascript:" + jsPopupVars);
        return jsPopupVars.toString();
      }
    }
    return null;
  }