1 Reply Latest reply on Sep 23, 2009 11:26 AM by John Ament

    Display "Success" after email is sent

    Alex Cougarman Apprentice

      Hi. I've got a bunch of pages with web forms. When the user submits each, the page calls a method utilities.sendEmail() to send a Seam email. The method gets the name of the email filename for that form as argument. Here's the call to the method:


      <a4j:commandButton action="#{utilities.sendEmail('/pages/web-encode/mail.xhtml')}" /> 



      Here's the sendEmail() method:


      public String sendEmail(String mailFile) throws SMTPSendFailedException {
        status = "Processing email now...";
        renderer.render(mailFile);
        status = "Email sent successfully."; 
        renderer = null;
        
        return "/index.xhtml";
      }



      After sending the email, the method returns the redirect page's name (the index page). I'd like to display a message such as Email sent successfully for 'PAGENAME'. on the index page to indicate the email was sent or it failed. Using the a4j:status won't work because the utilities class isn't session-scoped (it's used by all the forms). If the user is coming to the index page without having sent an email (such as from a link), no message should be given. How do you do this? Thanks.