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
t.deepthi05t.deepthi05 

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

 

souvik9086souvik9086

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

 

t.deepthi05t.deepthi05

Thanks for the reply,I tried but still it is not displaying....

souvik9086souvik9086

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

 

t.deepthi05t.deepthi05

No still i am unable to display 

souvik9086souvik9086

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

 

t.deepthi05t.deepthi05

I kept system.debug statements and checked it is entering into the loop.

souvik9086souvik9086

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

 

vikas88vikas88

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

Ramakrishnan AyyanarRamakrishnan Ayyanar
Hi t.deepthi05,

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);