You need to sign in to do that
Don't have an account?
enrydev
Visual force error message in a new page
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.
There are different ways to do this. Take your pick from below:
Both of these should work. Just try and let us know if this works. Please mark this as a solution so that it helps others.
Thanks a lot, this works:
page 2: