コード例 #1
0
  public void handle(
      HttpServletRequest request, HttpServletResponse response, RequestContext context) {
    SimpleRequestContext src = (SimpleRequestContext) context;
    FormImpl f = prepareForm("toadmin".equalsIgnoreCase(src.getNotNullString("type")));
    src.setObject(ACSConstants.FORM_ATTRIBUTE_NAME, f);
    if (src.getString("message_body") != null) {
      ((HtmlFormInputElement) f.getElementByName("message_body"))
          .setValue((String) src.getObject("message_body"));
      ((HtmlFormInputElement) f.getElementByName("recipient"))
          .setValue((String) src.getObject("recipient"));

      boolean res =
          Messenger.sendMessage(
              src.getString("message_body"),
              (UserAccaunt) request.getSession().getAttribute(ACSConstants.ACCAUNT_ATTRIBUTE_NAME),
              src.getString("recipient").equalsIgnoreCase(UserManager.TESH_SUPPORT.getLogin())
                  ? new TechSupportRecipientFactory()
                  : new UserRecipientFactory(src.getString("recipient")));

      if (res)
        ((ACSRequestContext) context)
            .addMessage(new StatusMessage("Сообщение отправленно", StatusMessageType.OK_MESSAGE));
      else
        ((ACSRequestContext) context)
            .addMessage(
                new StatusMessage("Сообщение не отправленно", StatusMessageType.ERROR_MESSAGE));
    }
  }
コード例 #2
0
  private FormImpl prepareForm(boolean isToAdmin) {
    FormImpl form = new FormImpl("acsform");
    form.setFormUserName("Форма отправки сообщения");
    form.setName("writemessage");

    form.addElement(getRecipient(isToAdmin));

    TextareaElement tae = new TextareaElement();
    tae.setCols(45);
    tae.setFormName("writemessage");
    tae.setName("message_body");
    tae.setRows(5);
    tae.setTabindex(7);
    tae.setUserName("Сообщение");
    tae.setCheckJs(HtmlConstants.CHECK_NOT_NULL);
    tae.setErrorMessage("Введите сообщение");
    form.addElement(tae);

    form.addElement(new SubmitElement("sb", "Отправить"));

    return form;
  }