コード例 #1
0
  /**
   * Action handler - gets invoked on send mail click button
   *
   * @param actionEvent
   * @throws Exception
   */
  public void sendMessage(ActionEvent actionEvent) throws Exception {
    try {
      Map<RecipientType, String[]> recipientDetails = new HashMap<RecipientType, String[]>();
      List<String> errorMsg = validateMailAddresses(recipientDetails);

      if (errorMsg.size() == 0) {
        String mailContent = editor.getContent();
        // Replace with <br/>, to maintain multiline msg entered on TextArea
        mailContent = mailContent.replaceAll("(\r\n|\n)", "<br />");
        // Send mail
        boolean sendMailSuccess =
            mailService.sendMail(
                recipientDetails, mailSender, mailSubject, mailContent, attachments);

        if (sendMailSuccess) {
          // Save document
          saveEmailDocument();
          PortalApplication.getInstance().closeFocusView();
        }
      } else {
        StringBuilder sb = new StringBuilder();
        for (String msg : errorMsg) {
          sb.append(msg);
          sb.append(",");
          sb.append("\n");
        }
        MessageDialog.addErrorMessage(sb.toString());
      }
    } catch (Exception e) {
      ExceptionHandler.handleException(e);
    }
  }
コード例 #2
0
  /**
   * @param document
   * @param addAtTop
   * @return
   */
  private boolean addTemplate(Document document, boolean addAtTop) {
    if (isDocumentTemplate(document)) {
      String tempContent =
          new String(
              DocumentMgmtUtility.getDocumentManagementService()
                  .retrieveDocumentContent(document.getId()));

      tempContent = resolveExpressions(tempContent);

      editor.addContent(
          tempContent,
          addAtTop ? DocumentEditingPolicy.ADD_AT_TOP : DocumentEditingPolicy.ADD_AT_BOTTOM);

      return true;
    } else {
      MessageDialog.addErrorMessage(
          this.getMessages().getString("invalid.template.message")
              + " "
              + document.getContentType());
      return false;
    }
  }