I'm creating a custom VF page for the registration of new users.
Page: simple form to get the user's email.
Controller:
public with sharing class SiteRegisterController {
public SiteRegisterController () {
}
public String username {get; set;}
public String email {get; set;}
public String password {get; set;}
public PageReference registerUser() {
user u = [select id,username from User where username = :email];
if (u!=null) {
//ADD HERE CODE FOR ERROR MESSAGE IN THE PAGE FORGOTPASSWORD
PageReference page = System.Page.ForgotPassword;
page.setRedirect(true);
return page;
}
else {
PageReference page = new PageReference('http://registration.com/');
page.setRedirect(true);
return page;
}
return null;
}
}
If the user is already registered i would like also add a message "You are already registered, Did you forget your password?" on the new page System.Page.ForgotPassword;. I know how to add an eror message in the current page
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.');
ApexPages.addMessage(myMsg);
but is it also possible add it in a new page(forgotpassword) from the controller of the current page?
Of course in the page forgot password there is a tag <apex:pageMessages id="error"/>
Thanks in advantage for any advice.
BR.