0 Replies Latest reply on Jul 1, 2009 12:25 PM by Alex Cougarman

    Send email and display status using modalPanel

    Alex Cougarman Apprentice

      Hi. I've got a Seam app that sends the data from a form to an email address. When the user clicks Submit, it displays any validation errors in a <rich:modalPanel>; otherwise, it sends the email.

      I've been pulling my hair out trying to figure out how to display the status of the email ("Sending email...", "Email sent successfully.") in a modalPanel and haven't had any success.

      Here's what I've got for the Submit button and the modalPanel that displays the validation errors:

      <a4j:commandButton action="#{newemployee.sendEmail()}" value="Submit"
       oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'mpErrors\');' : 'Richfaces.showModalPanel(\'mpErrors\');'}"/>
       <rich:modalPanel id="mpErrors" width="350" height="250">
       <f:facet name="header">
       <h:graphicImage value="/img/msginfo.png" style="float:left; margin-right: 3px;" />
       <h:outputText value="System Messages" />
       <f:facet name="controls">
       <h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelinkmpErrors"/>
       <rich:componentControl for="mpErrors" attachTo="hidelinkmpErrors" operation="hide" event="onclick"/>
       <a4j:outputPanel ajaxRendered="true" style="width:100%">
       <rich:messages passedLabel="Data is allowed to be emailed."
       style="width:100%; text-align: left; color: red; font-weight: bold;" rendered="#{facesContext.maximumSeverity == null ? 'false' : 'true'}"
       <f:facet name="errorMarker">
       <h:graphicImage style="margin-right: 5px;" value="/img/msgerror.png" />
       <div style="text-align:center">
       <a4j:commandButton style="text-align:center; margin: 29px;" id="btnReturn" value="Return to Form" >
       <rich:componentControl for="mpErrors" attachTo="btnReturn" operation="hide" event="onclick"/>

      Here's the code for the sendEmail() method:

      @In private Renderer renderer;
       public void sendEmail() {
       status = (this.isHasMessages()) ? "Validation errors occurred." :
       "Processing email now...";
       try {
       status = "Email sent successfully.";
       catch (javax.faces.FacesException e) {
       status = "An error occurred while sending the email: " + e.getMessage();

      How do I display the status of the email using the <a4j:status> in a modalPanel? Thanks.