Activity Forums Salesforce® Discussions Differences between all of the messaging options

  • Differences between all of the messaging options

  • Satyakam

    Member
    April 29, 2016 at 2:03 pm

    what is the differences between all of the messaging options Visualforce provides, such as apex:message, apex:messages, apex:pageMessage, and apex:pageMessages..?

  • Piyush

    Member
    April 29, 2016 at 2:27 pm
  • shariq

    Member
    September 18, 2018 at 3:41 pm

    Hi,

    <apex:message> :

    A message for a specific component, such as a warning or error. If an or component is not included in a page, most warning and error messages are only shown in the debug log.

    <apex:messages> :

    All messages that were generated for all components on the current page. If an or component is not included in a page, most warning and error messages are only shown in the debug log.

    <apex:pageMessage> :

    This component should be used for presenting custom messages in the page using the Salesforce pattern for errors, warnings and other types of messages for a given severity.

  • Parul

    Member
    September 18, 2018 at 6:01 pm

    Hi

    Add more point:

    <apex:pageMessage>

    This component is used to dispaly custom messages with severity error,warning etc.  in the VF page.

    <apex:page controller="MyRegisterCon2" sidebar="false" docType="HTML-5.0"   >

    <apex:form >
    <apex:pageBlock >
    <apex:pageblockSection columns="1" >
     <apex:pageMessage summary="This is page message"  severity="warning" strength="3" />
    <apex:inputtext value="{!FirstName}" label="First Name"  />
    <apex:inputtext value="{!LastName}" label="Last Name" />
    <apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
    <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />
    </apex:pageblockSection>
    <apex:pageBlockButtons >
    <apex:commandButton value="submit" action="{!save}" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form></apex:page>

     

    <apex:pageMessages>

    The  above component provides the SF styling for the messages. 

    <apex:page controller="MyRegisterCon2" sidebar="false" docType="HTML-5.0"   >

    <apex:form >
    <apex:pageBlock >
    <apex:pageblockSection columns="1" >
    <apex:pageMessages />
    <apex:inputtext value="{!FirstName}" label="First Name"  />
    <apex:inputtext value="{!LastName}" label="Last Name" />
    <apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
    <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />
    </apex:pageblockSection>
    <apex:pageBlockButtons >
    <apex:commandButton value="submit" action="{!save}" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form></apex:page>

     

    <apex:messages>

    Include above code in VF page it will display all the messages . If we observe styling was not applied to the messages.

    <apex:page controller="MyRegisterCon2" sidebar="false" docType="HTML-5.0"   >

    <apex:form >
    <apex:pageBlock >
    <apex:pageblockSection columns="1" >
    <apex:messages />
    <apex:inputtext value="{!FirstName}" label="First Name"  />
    <apex:inputtext value="{!LastName}" label="Last Name" />
    <apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
    <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />
    </apex:pageblockSection>
    <apex:pageBlockButtons >
    <apex:commandButton value="submit" action="{!save}" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form></apex:page>

     

    <apex:message>:

    This component is used to display warning or error message for a specific component.

    Change visualforce to following code.

    <apex:page controller="MyRegisterCon2" sidebar="false" docType="HTML-5.0"   >

    <apex:form >
    <apex:pageBlock >
    <apex:pageblockSection columns="1" >
    <apex:message for="phone" />
    <apex:inputtext value="{!FirstName}" label="First Name"  />
    <apex:inputtext value="{!LastName}" label="Last Name" />
    <apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
    <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />

    </apex:pageblockSection>
    <apex:pageBlockButtons >
    <apex:commandButton value="submit" action="{!save}" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>

    </apex:page>

     

    Hope this will help you.

     

    Thanks

Viewing 1 - 4 of 4 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Pros & Cons of Lightning Component vs. 3rd party frameworks in Salesforce UI development

Video in

Nikita drops by to share his invaluable experience of using popular 3rd party frameworks in Salesforce. http://media.blubrry.com/salesforceway/audio.xmcdn.com/group42/M05/25/57/wKgJ81rXk6XjaZIAAU_I_KtprFM998.m4a