You need to sign in to do that
Don't have an account?
Page Message
Hi,
I am unable to display page message in my vf page.
the following is the code.
<apex:page controller=" xyz">
<apex:outputPanel id=panelid>
</pageMessages>
<apex:commandlink action="{reference}" value=" save and send" rerender="panelid">
</apex:outputPanel>
</apex:page
-----------------------------------------------------------------------------------------------
controller code
public pagerefernce reference(){
set<string> emails = new set<string>();
/checkValid EMails
for(String e :emails){
checkEmail(e);
if(isValid(e)){
system.debug('check email is not completed calledcccccc');
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Check your email');
ApexPages.addMessage(myMsg);
}
}
if(vEmails.size()==eMessage.size()){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'At least one email is mandatory'));
}
for(ApexPages.Message message : ApexPages.getMessages()){
System.debug(message.getComponentLabel() + ' : ' + message.getSummary());
}
return null;
}
//validate Email
public boolean isValid(String email){
// Regular Expression for email
String emailRegex = '^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$';
Pattern MyPattern = Pattern.compile(emailRegex);
// then instantiate a new Matcher object ”MyMatcher”
Matcher MyMatcher = MyPattern.matcher(email);
if (!MyMatcher.matches()) {
return true;
}else{
return false;
}
}
Thanks & Regards
Change like this
<apex:page controller=" xyz">
<apex:outputPanel id=panelid>
<apex:pagemessages />
<apex:commandlink action="{reference}" value=" save and send" rerender="panelid">
</apex:outputPanel>
</apex:page>
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Thanks for the reply,I tried but still it is not displaying....
Keep it ouside outputpanel as it is rerendering it message may become null
<apex:page controller=" xyz">
<apex:pagemessages />
<apex:outputPanel id=panelid>
<apex:commandlink action="{reference}" value=" save and send" rerender="panelid">
</apex:outputPanel>
</apex:page>
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
No still i am unable to display
Please make sure that the flow is entering the condition
if(isValid(e)){
}
This is an error message. So can you please explain the condition you gave.
The condition will be if it is not valid then the error will be displayed.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
I kept system.debug statements and checked it is entering into the loop.
Then please check in debug the value of myMsg after adding the error message and see whether it is printing null or what.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Hi,
Try this:
<apex:outputPanel id=panelid>
<apex:pageMessages ></apex:pageMessages>
</apex:outputPanel>
<apex:commandlink action="{reference}" value=" save and send" rerender="panelid">
if this is your solution please marked it as solved
try this .
Page:
<apex:page controller=" xyz">
<apex:pagemessages />
<apex:outputPanel id=panelid>
<apex:commandlink action="{reference}" value=" save and send" rerender="panelid">
</apex:outputPanel>
</apex:page>
Controller:
Display the page message code.
ApexPages.Message ErrorMessage = new ApexPages.Message(ApexPages.Severity.Info, 'Test Error');
ApexPages.addMessage(ErrorMessage);