function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
new_bienew_bie 

apexpages.message statements?

Hi

 

i am confused to below statement, can you explain the staments. 

 

Apexpages.addMessge(new apexpages.message(apexpages.severity.info,'error message'))

 

Apexpages.message mymsg=new Apexpages.message(apexpages.severity, summary, detail);

 

how many ways create a object in apex?

 

 

Regards..

Best Answer chosen by Admin (Salesforce Developers) 
Saravanan @CreationSaravanan @Creation

Hi,

 

No need confuse its very easy.

 

Apexpages.message mymsg=new Apexpages.message(apexpages.severity, summarydetail);

 

From the above line just you are creating intance for 'Apexpages.message' with value . here 'summarydetail' is value

for severity under apexpages.

 

if you want to display this message on the page the you need to use 'addMessge' like below line

 

ApexPages.addmessage(mymsg);

 

then only the above message will display on visualforcepage. for more info for ApexPages methods click here

 

 

insteed of writting two line of code we will make it simple like below line.

 

Apexpages.addMessge(new apexpages.message(apexpages.severity.info,'error message'))

 

 

All Answers

Saravanan @CreationSaravanan @Creation

Hi,

 

No need confuse its very easy.

 

Apexpages.message mymsg=new Apexpages.message(apexpages.severity, summarydetail);

 

From the above line just you are creating intance for 'Apexpages.message' with value . here 'summarydetail' is value

for severity under apexpages.

 

if you want to display this message on the page the you need to use 'addMessge' like below line

 

ApexPages.addmessage(mymsg);

 

then only the above message will display on visualforcepage. for more info for ApexPages methods click here

 

 

insteed of writting two line of code we will make it simple like below line.

 

Apexpages.addMessge(new apexpages.message(apexpages.severity.info,'error message'))

 

 

This was selected as the best answer
new_bienew_bie
Hi Saravanan

thanks for immediate response.

How many ways create instance in apex.

Regards.
Saravanan @CreationSaravanan @Creation

Hi,

 

Only one way to create the instance in apex by using 'new' key word.

 

if you look at below two line


Apexpages.addMessge(new apexpages.message(apexpages.severity.info,'error message'))

Apexpages.message mymsg=new Apexpages.message(apexpages.severity, summary, detail);

 

In the first line you are creating instance by using 'new ' keyword but you didn't assign to any variable 

but in the second line you are assigning to 'mymsg' Apexpages.message variable.

 

only this is the bifference but the way of creation is same.

 

So, you can get to know there is only one way to create the instance .

new_bienew_bie
Hi saravanan

Thanks for your valuable information.

Regards