HTML and CSS Reference
In-Depth Information
The registration form includes the corresponding input fields to the Mega App user attributes, which were
described in Listing 13-9. When the user clicks the "Register User" command button, and using the <f:ajax>
tag, the registration form attributes are sent to the server, #{userAddBacking.registerUser} action method is
executed, and finally either a success message or a failure message(s) is rendered to the client. Listing 13-25 shows
UserAddBacking CDI managed bean.
Listing 13-25. UserAddBacking CDI Managed Bean
package com.jsfprohtml5.megaapp.backing;
import com.jsfprohtml5.megaapp.model.MegaUser;
import com.jsfprohtml5.megaapp.service.MegaUserManagerLocal;
import com.jsfprohtml5.megaapp.service.exception.UserAlreadyExists;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.faces.application.FacesMessage;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
public class UserAddBacking extends BaseBacking implements Serializable {
private MegaUserManagerLocal userManager;
private MegaUser newUser = new MegaUser();
private String infoMessage;
public String getInfoMessage() {
return infoMessage;
public void setInfoMessage(String infoMessage) {
this.infoMessage = infoMessage;
public String registerUser() {
if (! newUser.getPassword().equals(newUser.getPassword2())) {
getContext().addMessage(null, new FacesMessage("Passwords must be identical"));
return null;
Search WWH ::

Custom Search