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
mariappangomathirajmariappangomathiraj 

Apex:messages didn't show in VF page(clicking the button action)

I have added some ApexPages.Message in My controller.Its running in unauthenticated site(Guest User).I have added one ApexPages.Message in constructor.And other messages in One method.But Only constructor ApexPages.Message showing in the VF page.Method ApexPages.Message didn't showi in that page.

 

In the debug logs error message is displaying but in the visual force page it is not showing.

Always its goto unauthorized page.Please help.

 

My page code :

<apex:page controller="updateContact" showHeader="false" sidebar="false" standardStylesheets="false">


<apex:form Id="Contact_update" forceSSL="true">

<apex:pageMessages/>

<div class = "updateButtonDiv">
<apex:commandbutton action="{!registerUsers}" rerender="Contact_update"/>
</div>
</apex:form>

</apex:page>

 

My controller code :

 

public class updateContact {

public string contactId;
public Contact contact {get;set;}

public updateContact() {

contactId= ApexPages.currentPage().getParameters().get('conatctid');
try{
contact = [select Id,email from contact where id=:contactId];
}
catch(Exception e){
// hasError = true;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL,'No Contact ID was passed to this form so your contact information cannot be updated. '+contactId);
ApexPages.addMessage(myMsg);
System.debug(':::::::::::::::::::::Error: '+e.getMessage());
return;
}
}

public PageReference registerUsers() {
try{
if (!checkEmail()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'That email already exists.');
ApexPages.addMessage(msg);
system.debug('::::msg::::::::::::::'+msg);
return null;
}
catch(Exception e) {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Internal server error. '+e));
}
return null;
}


// check if this username alredy exists
private boolean checkEmail() {
List<User> uList = [select id from User where username =: contact.email ];
return uList.isEmpty();
}
}