This is a simple way of displaying message when a user login (if validating using backing bean).
1) Drag and drop a Message component on the page.
2) Under the action listener method of the login button add following code
FacesMessage msg=null;
FacesContext fc=FacesContext.getCurrentInstance();
If login successful :
msg= new FacesMessage("Welcome");
fc.addMessage(null,msg);
If login failed:
1) Drag and drop a Message component on the page.
2) Under the action listener method of the login button add following code
FacesMessage msg=null;
FacesContext fc=FacesContext.getCurrentInstance();
If login successful :
msg= new FacesMessage("Welcome");
fc.addMessage(null,msg);
If login failed:
msg= new FacesMessage("Invalid Username/Password");
fc.addMessage(null,msg);
3) Now just run the app and test.
No comments:
Post a Comment