1 Reply Latest reply on Jun 15, 2009 6:50 PM by Alex Cougarman

    Redirect after sending email

    Alex Cougarman Apprentice

      This might be a beginner question: I've got the following method in a Seam class (with the @Name annotation), and need to redirect the user after the email is sent successfully:


           public void sendEmail() {
                try {
                     renderer.render("/mail.xhtml");
                     message = "Email sent successfully.";
                     // redirect user to the page "/done.xhtml"
                }
                catch (javax.faces.FacesException e) {
                     message = "An error occurred while sending the email: " + e.getMessage();
                }
           }



      Here's the button on the page that calls the above code:


      <a4j:commandButton action="#{asset.sendEmail()}" value="Send Eamil" />



      How do you redirect the user from the Seam class? Thanks.



        • 1. Re: Redirect after sending email
          Alex Cougarman Apprentice

          I think the answer is this:


               public String sendEmail() {
                    String redirect = "/done.xhtml";
                    try {
                         renderer.render("/mail.xhtml");
                         message = "Email sent successfully.";
                         return redirect;
                    }
                    catch (javax.faces.FacesException e) {
                         message = "An error occurred while sending the email: " + e.getMessage();
                         return redirect;
                    }
               }



          Sorry for the stupid question :)