Administration interface

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: ...

Get JBoss Weld CDI for Java Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.