/**
   * Handle actions for the DeleteRecordDelegate.
   *
   * @throws IOException, standard exception thrown by servlet methods.
   * @throws ServletException, standard exception thrown by servlet methods.
   */
  public void run() throws IOException, ServletException {
    try {
      // validate
      Util.argCheckNull(_request);
      Util.argCheckNull(_response);

      // make the cell
      MdnClientCell client = new MdnClientCell();
      client.setAlign(AlignType.CENTER);
      client.setClientTitle(ConfirmDeleteDelegate.TEXT_DELETE_TITLE.getText());
      client.setHelpUrl("/help/mdnhelp.html#bDeleteRecord");

      // table and title
      WslHtmlTable table = new WslHtmlTable();
      client.addElement(table);
      TD cell =
          new TD(MdnHtmlServlet.getTitleElement(ConfirmDeleteDelegate.TEXT_DELETE_TITLE.getText()));
      cell.setColSpan(2);
      TR row = new TR(cell);
      table.addElement(row);

      // get the rec index
      String strIndex = _request.getParameter(MdnHtmlServlet.PV_RECORD_INDEX);
      if (strIndex != null && strIndex.length() > 0) {
        int index = Integer.parseInt(strIndex);

        // get the record
        PagedSelectDelegate psd = (PagedSelectDelegate) getUserState().getCurrentPagedQuery();
        Record rec = psd.getRecord(index);
        if (rec != null) {
          // delete the record
          rec.delete();

          // delegate to query
          int queryId = psd.getQueryId();
          String strQueryId = String.valueOf(queryId);
          delegate(new QueryRecordsDelegate(strQueryId));
          return;
        } else
          table.addElement(
              new TR(new TD(WslHtmlUtil.esc(MdnHtmlServlet.ERR_REC_NOT_FOUND.getText()))));
      } else
        table.addElement(
            new TR(new TD(WslHtmlUtil.esc(MdnHtmlServlet.ERR_REC_NOT_FOUND.getText()))));

      // send output
      outputClientCell(client);
    } catch (Exception e) {
      onError(ERR_DELETE.getText(), e);
    }
  }
예제 #2
0
  /** @return Record the current record */
  public Record getRecord(HttpServletRequest request) {
    // get the index param
    Record rec = null;
    String strIndex = request.getParameter(MdnHtmlServlet.PV_RECORD_INDEX);
    if (strIndex != null && strIndex.length() > 0) {
      int index = Integer.parseInt(strIndex);

      // get the record
      if (index >= 0) {
        PagedSelectDelegate psd = (PagedSelectDelegate) getCurrentPagedQuery();
        rec = psd.getRecord(index);
      } else rec = getCurrentNewRecord();
    }

    // return
    return rec;
  }