+ Start a Discussion

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">


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



My controller code :


public class updateContact {

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

public updateContact() {

contactId= ApexPages.currentPage().getParameters().get('conatctid');
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);
System.debug(':::::::::::::::::::::Error: '+e.getMessage());

public PageReference registerUsers() {
if (!checkEmail()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'That email already exists.');
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();