private void generateDivHtml(PrintWriter p, int rowNo) throws DataStoreException {
   if (!_showDescription) return;
   if (_editDescription) return;
   p.print(_fontStartTag);
   p.print("<span id=\"div");
   p.print(getFullName());
   if (rowNo != -1) p.print("_" + rowNo);
   p.print("\">");
   if (_descriptionEval != null) {
     if (rowNo == -1) rowNo = _descriptionEval.getDataStore().getRow();
     Object o = _descriptionEval.evaluateRow(rowNo);
     if (o != null) {
       p.print(o);
       _hiddenDescriptionHandle.setValue(o.toString());
     } else {
       _hiddenDescriptionHandle.setValue(null);
     }
   } else {
     // Take the description from the hidden field value
     p.print(
         _hiddenDescriptionHandle.getValue() == null ? "" : _hiddenDescriptionHandle.getValue());
   }
   p.print("</span>");
   p.print(_fontEndTag);
 }
  public void pageRequested(PageEvent p) throws Exception {
    HttpServletRequest req = p.getPage().getCurrentRequest();
    String returnVal[] = req.getParameterValues(getFullName());
    if (returnVal != null) {
      if (_editDescription) _hiddenKeyHandle.setValue(returnVal[0], _rowNo);
      else getEditField().setValue(returnVal[0], _rowNo);
    }
    HtmlPage pg = getPage();
    if (pg instanceof JspController) ((JspController) pg).setRemoveFromQueryString(getFullName());

    if (returnVal != null) {
      returnVal = req.getParameterValues("descReturn");
      if (returnVal != null) {
        if (_editDescription) getEditField().setValue(returnVal[0], _rowNo);
        if (_descDs != null && _descriptionColumn != -1) {
          if (_descDs.getColumnDataType(_descriptionColumn) == DataStoreBuffer.DATATYPE_STRING) {
            if (_rowNo == -1) _rowNo = _descDs.getRow();
            _descDs.setString(_rowNo, _descriptionColumn, returnVal[0]);
          }
        }
        if (pg instanceof JspController)
          ((JspController) pg).setRemoveFromQueryString("descReturn");
      }
    }
  }
 private boolean setEditReadOnly(int rowNo) {
   boolean ret = getEditField().getReadOnly();
   if (_editDescription)
     getEditField()
         .addOnChange(
             getFormString()
                 + _hiddenKeyHandle.getFullName()
                 + (rowNo != -1 ? "_" + rowNo : "")
                 + ".value=''");
   return ret;
 }
  public String getHiddenKeyFieldFullName(int rowNum) {
    String hiddenKeyFullName = null;
    String formString = null;
    if (getPage() != null) {
      hiddenKeyFullName = _hiddenKeyHandle.getFullName();
      if (rowNum > -1) hiddenKeyFullName += "_" + rowNum;
      formString = getEditField().getFormString();
    }

    if (hiddenKeyFullName == null) return null;
    else return formString + hiddenKeyFullName;
  }
  /**
   * 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);
  }
 /** Sets the column in the DataStore that this field binds to */
 public void setColumn(DataStoreBuffer ds, String columnName) {
   if (!_editDescription) getEditField().setColumn(ds, columnName);
   else _hiddenKeyHandle.setColumn(ds, columnName);
   _ds = ds;
 }
 /**
  * @param editDescription Sets whether or not the description is editable. If the description is
  *     editable, the key field will not be displayed, but will be set by the lookup.
  */
 public void setEditDescription(boolean editDescription) {
   _editDescription = editDescription;
   _hiddenKeyHandle.setVisible(editDescription);
 }