How can I have some sort of confirmation saying that "Your record is added successfully" just to to give the good user experience? some sort of confirmation to the UI either by message or popup?

   <apex:pageblock id="Selected_PBS" title="{!IF(SelectedContacts != NULL && SelectedContacts.size > 0,'Selected Contact','There are no records selected')}">   
        <div align="center" style="padding:15px;" rendered="{!IF(SelectedContacts != NULL && SelectedContacts.size > 0,'Selected Contact','There are no records selected')}">            
              <apex:commandButton value="Add to Work Order!" action="{!addToWO}" disabled="{!If(selectedContacts != null && selectedContacts.size > 0,false, true)}" />
        <apex:pageBlockTable value="{!SelectedContacts}" var="contact" rendered="{!IF(SelectedContacts != NULL && SelectedContacts.size > 0,true,false)}">
             <apex:column value="{!contact.Name}"/>
             <apex:column value="{!contact.Email}"/>
             <apex:column value="{!contact.Phone}"/>

   public PageReference addToWO() 
      //more code....
      return null;

You can use the ApexPages.addMessage() method like this:

ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO, 'Record Saved Successfully'));

These messages that you add to the page will display anywhere that you place an <apex:pageMessages /> tag on your page.

  • Will that be display on the visual force page? Or need a placeholder to show? – Nick Kahn Jul 20 '15 at 20:36
  • I have very long page so this activity is happening at the bottom of the page – Nick Kahn Jul 20 '15 at 20:37
  • Oh, sorry - Yes it will display anywhere you put an <apex:pageMessages /> tag, so you can put a tag on both the top and bottom of the page and is should display in both. – LyBer Jul 20 '15 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.