Пример #1
0
  /**
   * Validate html with regular expression
   *
   * @param html html content for validation
   * @return Vector links and link text
   */
  public ArrayList<HtmlLink> grabHTMLLinks(final String html) {

    ArrayList<HtmlLink> result = new ArrayList<>();

    Matcher matcherTag = patternTag.matcher(html);

    while (matcherTag.find()) {

      String href = matcherTag.group(1); // href
      String linkText = matcherTag.group(2); // link text

      Matcher matcherLink = patternLink.matcher(href);

      while (matcherLink.find()) {

        String link = matcherLink.group(1); // link
        HtmlLink obj = new HtmlLink();
        obj.setLink(link);
        obj.setLinkText(linkText);

        result.add(obj);
      }
    }

    return result;
  }
Пример #2
0
  /**
   * LookUp constructor.
   *
   * @param name - name of component
   * @param lookup_page - the page that will provide the lookup values
   * @param browseImage - the browse image to use. default is a magnifying glass
   * @param ds - DataStore that is being used with this component
   * @param tableName - table name to bind to
   * @param columnName - column name to bind to
   * @param dataType - data type of the main edit field ( use DataStore.DATATYPE_*)
   * @param pKey - flag that signifies if the column is a primary key column
   * @param p - page the component will be associated with
   */
  public HtmlLookUpComponent(
      String name,
      String lookup_page,
      String browseImage,
      DataStore ds,
      String tableName,
      String columnName,
      int dataType,
      boolean pKey,
      HtmlPage p) {
    super(name, p);

    _hiddenDescriptionHandle = new HtmlHiddenField("hiddenDescr", null, p);
    addCompositeComponent(_hiddenDescriptionHandle, DataStore.DATATYPE_STRING, false, null, null);
    _hiddenKeyHandle = new HtmlHiddenField("hiddenKey", null, p);
    addCompositeComponent(_hiddenKeyHandle, DataStore.DATATYPE_STRING, false, null, null);
    _hiddenKeyHandle.setVisible(false);

    setTheme(null);
    p.addPageListener(this);

    HtmlTextEdit edit = null;

    if (ds == null) {
      edit = new HtmlTextEdit("_edit", p);
      _editHandle = addCompositeComponent(edit, dataType, false, null, null);
    } else {
      _ds = ds;
      /** Don't add the same column twice to the data store. */
      if (_ds.getColumnIndex(tableName + "." + columnName) == -1) {
        if (_ds instanceof DataStore)
          ((DataStore) _ds).addColumn(tableName, columnName, dataType, pKey, true);
      }
      edit = new HtmlTextEdit(tableName + "_" + columnName, p);
      edit.setColumn(_ds, tableName + "." + columnName);

      _editHandle = addCompositeComponent(edit, dataType, true, tableName, columnName);
    }

    _browseImage = new HtmlSubmitImage("browseImage", browseImage, p);
    _browseImage.addSubmitListener(this);
    _browseImageHandle = addCompositeComponent(_browseImage, DATATYPE_ANY, false, null, null);

    _browsePopupImage = new HtmlImage("browsPopupImage", browseImage, p);
    _browsePopupImageLink = new HtmlLink("browsePopupImageLink", null, p);
    _browsePopupImageLink.add(_browsePopupImage);
    _browseImageHandle =
        addCompositeComponent(_browsePopupImageLink, DATATYPE_ANY, false, null, null);
    _browsePopupImageLink.setVisible(false);

    setLookUpPageURL(lookup_page);
    setDescriptionFont(null);
  }
Пример #3
0
  /** @param b */
  public void setUsePopup(boolean b, boolean useModal) {
    _usePopup = b;
    /* Claudio Pi - 5/25/04 Added for modal popup windows */
    _useModal = useModal;

    if (_usePopup) {
      _browseImage.setVisible(false);
      _browsePopupImageLink.setVisible(true);
    } else {
      _browseImage.setVisible(true);
      _browsePopupImageLink.setVisible(false);
    }
  }
Пример #4
0
 /**
  * Sets the flag for ability to respond to user input (true = does respond).
  *
  * @param enabled boolean
  */
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   if (_editHandle instanceof HtmlFormComponent)
     ((HtmlFormComponent) _editHandle).setEnabled(enabled);
   if (_usePopup) _browsePopupImageLink.setVisible(enabled);
   else _browseImage.setVisible(enabled);
 }
Пример #5
0
  /**
   * This method will generate the html for each component in the page
   *
   * @param p - PrintWriter
   * @param rowNo - rowNo
   * @throws Exception
   */
  public void generateHTML(PrintWriter p, int rowNo) throws Exception {
    if (!_visible) {
      return;
    }

    // for each item in list
    JspCrumbleObject cro = null;
    HtmlText htText = null;
    HtmlText separatorText = null;
    HtmlLink hlLink = null;

    _cont.removeAll();

    int arrSize = _arrCrumble.size();

    if (arrSize <= 0) {
      return;
    }

    //  MessageLog.writeDebugMessage(" 1 generateHTML arrSize=" + arrSize, this);
    String croText = null;
    String croHref = null;

    for (int i = 0; i < arrSize; i++) {
      //      MessageLog.writeDebugMessage(" 1 generateHTML i=" + i, this);
      // create a link with text in it
      cro = (JspCrumbleObject) _arrCrumble.get(i);
      htText = null;
      croHref = cro.getHref();
      croText = cro.getText();

      if (Util.isFilled(croHref)) {
        htText = new HtmlText(croText, getCrumbleLinkFont(), getPage());
        htText.setFixSpecialHtmlCharacters(isFixSpecialHtmlCharacters());
        hlLink = new HtmlLink("hlLink" + i, croHref, getPage());
        hlLink.add(htText);
      } else {
        htText = new HtmlText(croText, getCrumbleFont(), getPage());
        htText.setFixSpecialHtmlCharacters(isFixSpecialHtmlCharacters());
      }

      // add link
      // add :
      String separator = getSeparator();

      if (!Util.isFilled(separator)) {
        separator = " : ";
      }

      separatorText = new HtmlText(separator, getCrumbleLinkFont(), getPage());
      separatorText.setFixSpecialHtmlCharacters(isFixSpecialHtmlCharacters());

      if (Util.isFilled(croHref)) {
        _cont.add(hlLink);
      } else {
        _cont.add(htText);
      }

      if (i < (arrSize - 1)) {
        _cont.add(separatorText);
      }
    }

    _cont.generateHTML(p, rowNo);
  }
Пример #6
0
  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;
  }
Пример #7
0
 public void removeImageLinkSubmitListener(SubmitListener listener) {
   if (listener != null) _browsePopupImageLink.removeSubmitListener(listener);
 }
Пример #8
0
 // add and remove SubmitListener methods was added by Juan Manuel Cortez on April/2008
 public void addImageLinkSubmitListener(SubmitListener listener) {
   if (listener != null) _browsePopupImageLink.insertSubmitListener(listener);
 }
Пример #9
0
 /**
  * Sets the flag for ability to respond to user input (true = does respond).
  *
  * @param enabled boolean
  */
 public void setReadOnly(boolean enabled) {
   // super.setEnabled(enabled);
   if (_editHandle instanceof HtmlTextEdit) ((HtmlTextEdit) _editHandle).setReadOnly(enabled);
   if (_usePopup) _browsePopupImageLink.setVisible(!enabled);
   else _browseImage.setVisible(!enabled);
 }