Wednesday, 22 August 2018

Different messages in visualforce

<apex:messages> :
==================

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

Note :
it is used to display an error on only a very specific field.it is used to allow the developer to place field specific errors in a specific location.

ex :

<apex:message for="phone" />
<apex:inputText value={!Phone} label="Phone"
id="Phone" />


<apex:messages> :
================
This component display all the error messages.These errors are displayed as a list with no
styling.

ex :
<apex:messages />
<apex:inputText value={!Phone} label="Phone"
id="Phone" />
<apex:inputText value={!DOB} label="DOB"
id="dob" />

<apex:PageMessages> :
======================

This Component provides the salesforce styling for the messages.

it is used to display all of the messages on a page. it will display salesforce generated messages as well as custom messages added to the apex class.

ex :
 <apex:pageMessages />
<apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
  <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />

<apex:pageMessage> :
=====================
This component is used to display custom messages with severity error,warning etc
in the VF Page.

it is used to display a single custom message using the salesforce formatting.you can specify the severity and the strength

ex :
<apex:pageMessage summary="This is page message"  severity="warning" strength="3" />
<apex:input value="{!Jdate}" label="DOB" type="date" id="dob" />
  <apex:inputtext value="{!Phone}" label="Phone"  id="phone"  />

Note :

apex:pageMessages shows all of the errors with formatting,apex:pageMessage only shows
the specified message.

No comments:

Post a Comment