/** 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");
  }
  /** Exports object list. */
  protected ActionForward doExport() throws PureException {
    SearchForm thisform = (SearchForm) form;
    IObjects exObjs = null;
    try {
      // 1. to fetch the objects collection
      if (thisform.getExportMode() == SearchForm.EX_MODE_SELECTED
          && thisform.getExportIds() != null) {
        Class entityClass = thisform.getEntityMetadata().getEntityClass();
        IContentMgr mgr = ArkContentHelper.getContentMgrOf(entityClass);
        if (!isFromTemp()) {
          exObjs = mgr.lookupByIds(thisform.getExportIds());
        } else {
          String strSQL =
              "SELECT * FROM "
                  + thisform.getEntityMetadata().getTempTable()
                  + " WHERE {this.id} IN ("
                  + thisform.getExportIds()
                  + ")";
          ISession session = LocalContextHelper.currentSession();
          IStatement query = session.createQuery(strSQL, entityClass, 0);
          try {
            exObjs = query.executeQuery();
          } finally {
            query.clear();
          }
        }
      } else {
        exObjs = getIObjects();
      }

      // 2. to prepare the columns
      ListHelper lh = new ListHelper();
      lh.setSenery(getScenery());
      List baseCols = thisform.getColunms();
      String sClassName = exObjs.getElementClass().getName();
      if (baseCols == null || baseCols.size() < 1) {
        baseCols = lh.prepareBase(exObjs.getElementClass().getName());
      }

      lh.setSenery(getExportSenery());
      lh.setAct("content");

      List colInfos =
          lh.prepareColsInfo(baseCols, getInclude(), getExclude(), null, sClassName, false);
      String[] headers = new String[colInfos.size()];
      String[] properties = new String[colInfos.size()];
      SceneryContext sceneryContext = null;
      try {
        boolean bUsePropertyName = (thisform.getExportType() == ExportHelper.TYPE_XML);
        String sHeader;
        for (int i = 0; i < colInfos.size(); i++) {
          ColumnInfo colInfo = (ColumnInfo) colInfos.get(i);
          if (bUsePropertyName) {
            sHeader = colInfo.getOldName();
          } else {
            sHeader = colInfo.getTitle();
            if (sHeader.indexOf('$') >= 0) {
              if (sceneryContext == null) {
                IDVContextFactory factory =
                    (IDVContextFactory) PureFactory.getBean("IDVContextFactory");
                DolphinObject obj = (DolphinObject) exObjs.getElementClass().newInstance();
                sceneryContext =
                    factory.createSceneryContext(obj, getExportSenery(), "plain.default");
              }
              sHeader = Executer.execute(ScriptReader.readBlock(sHeader), sceneryContext);
            }
          }
          headers[i] = sHeader.replaceAll("[\\\\\\[\\]\\?/<>]+", "_");
          properties[i] = colInfo.getName();
        }
      } catch (Exception ex) {
        throw new PureException(ArkExceptionTypes.EXPORT_CONTENTS, "failed to get the headers", ex);
      } finally {
        if (sceneryContext != null) {
          sceneryContext.clear();
        }
        colInfos.clear();
      }

      // 3. to prepare the data
      IConvertor convertor = new ExportConvertor(getExportSenery(), "content");
      DolphinExportGoods goods = new DolphinExportGoods();
      goods.setType(thisform.getExportType());
      goods.setName(getTitle());
      goods.setHeaders(headers);
      goods.setData(exObjs, properties, convertor);

      // 4. to return
      request.setAttribute("export", goods);
      return mapping.findForward("guest-export");
    } finally {
      LocalContextHelper.closeSession();
    }
  }