+ Start a Discussion
Ranu JainRanu Jain 

SerializationException

hii,


System.SerializationException: Not Serializable: ApexPages.Message 

 

i initialze message object as a class variable....what should i have to do to remove this exception?

 

tahnks

Best Answer chosen by Admin (Salesforce Developers) 
hemantgarghemantgarg

Try it with later one, actually when you declare a variable at class level, then they become part of view state of the vf page and these Non-Serializables can't go into view state.

All Answers

hemantgarghemantgarg

It is not serialized, you can use it inside a method to add a message on vf page, but it cannot be used as a property.

Ranu JainRanu Jain

ohk i can not use it as a property but can i use it as a class variable and can initialise it as par my requirement....i mean

 

apex.mas msg;

  fun1()

{

msg=new apex.mas('message 1');

}

fun2()

{

msg=new apex.mas('messege 2');

}

 

or i have to use it in this way??

 

 

 

 

 

 

 

 

  fun1()

{

apex.mas msg =new apex.mas('message 1');

}

fun2()

{

apex.mas msg=new apex.mas('messege 2');

}

 

hemantgarghemantgarg

Try it with later one, actually when you declare a variable at class level, then they become part of view state of the vf page and these Non-Serializables can't go into view state.

This was selected as the best answer