protected Object lookupRefValue(String _sRef, Object _oKey, String _sForeignKey)
      throws Exception {
    if (_oKey == null) return null;

    // to analyze
    int nPos = _sRef.indexOf('.');
    String sRefTable = _sRef.substring(0, nPos);
    String sRefField = _sRef.substring(nPos + 1);

    // to construct SQL
    String fk =
        (_sForeignKey != null && (_sForeignKey = _sForeignKey.trim()).length() > 0)
            ? _sForeignKey
            : "ID";
    String strSQL = "SELECT " + sRefField + " AS VALUE FROM " + sRefTable + " WHERE " + fk + "=";
    if (_oKey instanceof String) {
      strSQL += "'" + ((String) _oKey).trim() + "'";
    } else {
      strSQL += _oKey.toString().trim();
    }

    // to execute query
    ISession session = this.getSession();
    IStatement query = session.createQuery(strSQL, DolphinObject.class, 1);
    IObjects results = query.executeQuery();

    // to fetch the result
    DolphinObject result = results.next();
    results.clear();
    query.clear();

    // to return
    return result == null ? null : result.getProperty("VALUE");
  }
  /** Shows object list in page. */
  protected ActionForward doList() throws PureException {
    SearchForm thisform = (SearchForm) form;

    List colInfos = null;
    IObjects iobjs = null;
    List objList = null;
    Pager pager = new Pager();

    // 1. to fetch the objects in current page
    try {
      pager.setPageSize(thisform.getPageSize());
      pager.setCurrPageIndex(thisform.getPage());

      int nMaxSize = pager.getPageSize() * (pager.getCurrPageIndex() + 1);
      iobjs = getIObjects(nMaxSize);

      if (iobjs == null) {
        pager.setItemCount(0);
      } else {
        pager.setItemCount(iobjs.getSize());
        objList = iobjs.toList(pager);
      }
    } finally {
      if (iobjs != null) iobjs.clear();
    }

    // 2. to prepare the head titles
    if (objList != null && objList.size() > 0) {
      ListHelper lh = new ListHelper();
      lh.setSenery(getScenery());
      colInfos =
          lh.prepareColsInfo(
              thisform.getColunms(),
              getInclude(),
              getExclude(),
              getReplace(),
              thisform.getEntityMetadata().getName(),
              true);
      lh.clear();
    }

    // 3. to prepare the result in page
    String sTitle = getTitle();
    request.setAttribute("title", sTitle == null ? "ап╠М" : sTitle);
    request.setAttribute("headTable", getHeadTable());
    request.setAttribute("objs", objList);
    request.setAttribute("pager", pager);
    request.setAttribute("colInfos", colInfos);
    request.setAttribute("tailedButtons", getTailedButtons());
    request.setAttribute("metaDatas", thisform.getEntityMetadata().getProperties());
    request.setAttribute("submitee", getSubmitee());
    request.setAttribute("scenery", getScenery());
    request.setAttribute("needExport", new Boolean(isNeedExport()));
    request.setAttribute("needRowSelector", new Boolean(isNeedRowSelector()));
    if (isNeedSerial()) {
      request.setAttribute("needSerial", new Boolean(true));
    }
    return mapping.findForward("success");
  }