Ejemplo n.º 1
0
  protected void deleteOperatorNumber(HttpServletRequest req) throws ServletException, IOException {

    String data = req.getParameter("deletePressed");
    if (data != null && data.startsWith(PREFIX_DELETE)) {
      int id = Integer.parseInt(data.substring(PREFIX_DELETE.length()));

      PhoneNumberBean phoneNumberBean = new PhoneNumberBean();
      phoneNumberBean.setPhoneNumberId(id);
      ApplicationManager.deletePhoneNumber(phoneNumberBean);
    }
  }
Ejemplo n.º 2
0
  protected void updateOperatorNumbers(HttpServletRequest req)
      throws ServletException, IOException {

    // Check for new item
    String newNote = req.getParameter("newNote");
    if (newNote != null && newNote.trim().length() > 0) {
      String newNumber = req.getParameter("newNumber");
      // //
      System.out.println("Found new Note & Number: " + newNote + " : " + newNumber);
      // //
      // Insert the new note and number
      PhoneNumberBean phoneNumberBean = new PhoneNumberBean();
      phoneNumberBean.setOwnerTypeId(OperatorBean.OPERATOR_TYPE_ID);
      phoneNumberBean.setPhoneTypeId(PhoneNumberBean.PHONETYPEID_WORK);
      phoneNumberBean.setNumber(newNumber);
      phoneNumberBean.setNote(newNote);
      ApplicationManager.insertPhoneNumber(phoneNumberBean);
    }
    // Update existing items
    Enumeration params = req.getParameterNames();
    while (params.hasMoreElements()) {
      String data = (String) params.nextElement();
      if (!data.startsWith(PREFIX_NOTE)) continue;
      String strId = data.substring(PREFIX_NOTE.length());
      String number = req.getParameter(PREFIX_NUMBER + strId);
      if (number == null) continue;
      String note = req.getParameter(data);
      // //
      System.out.println("About to update: " + note + " : " + number);
      // //
      // Update it...
      PhoneNumberBean phoneNumberBean = new PhoneNumberBean();
      phoneNumberBean.setPhoneNumberId(Integer.parseInt(strId));
      phoneNumberBean.setNumber(number);
      phoneNumberBean.setNote(note);
      ApplicationManager.updatePhoneNumber(phoneNumberBean);
    }
  }