To enable an administrator to login to the site, we need a CDI bean that JSF can use in the page, as shown in the following code:
@Named("login") @RequestScoped public class LoginBean { private String email; private String password; @Inject UserService userService; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public void submit() throws ServiceException { userService.login(email, password); } }
This bean will capture the login credentials and perform the login
operation on UserService
. The following is the JSF view that will be used for logging in:
<rich:panel> <f:facet name="header"> <h:outputText value="Login" /> </f:facet> <h:form> <h:panelGrid columns...