You need to sign in to do that
Don't have an account?

modify Apex pageMessages before displaying on VF pages
Hi,
We have added some validation rules to some of the fields. But when any validation fails, that error message gets displayed at the top of VF page with appended field lables at the start of error message.
For e.g If validation error message is added as Is manadatory then the error message displays that like Name: is manadation where Name is the field lable.
I want to remove this field lable from being appended to message, any help to edit these page messages before displaying on VF.
Thanks.
Hi,
You need to add server side validation.as:
if( variable != null && variable.length() > 0 ) {
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Put uor msg here');
ApexPages.addmessage(myMsg);
}
and remove the required=true from VF,in case of required attribute.
Please let me know if u have any problem on same and if this post helps u then plz give KUDOS by click on star at left.
Thanks for your reply.
But we do not want to hard code the message like this. Error message is already put while adding Validation rules for object. We want that when those messages gets displayed on VF page, it should be editable so taht we can remove the field lable from them.
We are not sure how to edir apes:pageMessages which is doing this.
Hi,
I don't think there is any way to edit VF page messages.
Please let me know if u have any problem on same and if this post helps u then plz give KUDOS by click on star at left.
Try adding an output text field at the top of the form and assign the error message to a string. Use some string methods to eliminate the field label from the message and display it using the output text.
I am getting error messages in <apex:pageMessages> tag.
How can I assign pageMessages to a string?
Can you please explain the same.
It would be helpful if you could post the vf code and the save method in your controller.
You can avoid this happing as you pass exception instance "e" as below :-
Try{
}Catch(Exception e)
{
ApexPages.addMessages(e);
}
Adds a list of messages to the current page context based on a thrown exception.