1 Reply Latest reply: Oct 25, 2012 12:10 AM by EJP RSS

    Problem when using Facade create() method

    970523
      I'm using Netbean 7.2
      jdk 7u7
      glassfish 3.2

      when i create new user (insert into database) using face method create() => get error

      Error: WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context /DemoPJ, because request parameters have already been read, or ServletRequest.getReader() has already been called
      WARNING: EJB5184:A system exception occurred during an invocation on EJB TblUsersFacade, method: public java.lang.Object SessionBean.AbstractFacade.find(java.lang.Object)
      WARNING: javax.ejb.EJBException
      at com.sun.ejb.containers.BaseContainer.processSystem Exception(BaseContainer.java:5215)
      at com.sun.ejb.containers.BaseContainer.completeNewTx (BaseContainer.java:5113)
      at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:4901)
      at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:2045)
      at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1994)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 22)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:89)
      at $Proxy327.find(Unknown Source)
      at SessionBean.__EJB31_Generated__TblUsersFacade__Int f____Bean__.find(Unknown Source)
      at JSFBean.UserBean.addUser(UserBean.java:111)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at javax.el.BeanELResolver.invokeMethod(BeanELResolve r.java:779)
      at javax.el.BeanELResolver.invoke(BeanELResolver.java :528)
      at javax.el.CompositeELResolver.invoke(CompositeELRes olver.java:257)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:24 8)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpre ssionImpl.java:302)
      at com.sun.faces.facelets.el.TagMethodExpression.invo ke(TagMethodExpression.java:105)
      at javax.faces.event.MethodExpressionActionListener.p rocessAction(MethodExpressionActionListener.java:1 48)
      at javax.faces.event.ActionEvent.processListener(Acti onEvent.java:88)
      at javax.faces.component.UIComponentBase.broadcast(UI ComponentBase.java:769)
      at javax.faces.component.UICommand.broadcast(UIComman d.java:300)
      at javax.faces.component.UIViewRoot.broadcastEvents(U IViewRoot.java:794)
      at javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:1259)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 01)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServl et.java:593)
      at org.apache.catalina.core.StandardWrapper.service(S tandardWrapper.java:1550)
      at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doServ ice(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMappe r$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMappe r.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(P rocessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(Proce ssorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(Process orTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute (DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtoc olFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(Defau ltProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(Defau ltProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(Htt pProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(Pr otocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(Selec tionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:7 1)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doW ork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run (AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.IllegalArgumentException: You have provided an instance of an incorrect PK class for this find operation. Class expected : class java.lang.Integer, Class received : class java.lang.String.
      at org.eclipse.persistence.internal.jpa.EntityManager Impl.findInternal(EntityManagerImpl.java:729)
      at org.eclipse.persistence.internal.jpa.EntityManager Impl.find(EntityManagerImpl.java:653)
      at org.eclipse.persistence.internal.jpa.EntityManager Impl.find(EntityManagerImpl.java:532)
      at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.find(EntityManagerWrapper.java:320)
      at SessionBean.AbstractFacade.find(AbstractFacade.jav a:36)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.glassfish.ejb.security.application.EJBSecurity Manager.runMethod(EJBSecurityManager.java:1052)
      at org.glassfish.ejb.security.application.EJBSecurity Manager.invoke(EJBSecurityManager.java:1124)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMet hod(BaseContainer.java:5388)
      at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvo cation.java:619)
      at com.sun.ejb.containers.interceptors.AroundInvokeCh ainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.ja va:571)
      at com.sun.ejb.containers.interceptors.SystemIntercep torProxy.doAround(SystemInterceptorProxy.java:162)
      at com.sun.ejb.containers.interceptors.SystemIntercep torProxy.aroundInvoke(SystemInterceptorProxy.java: 144)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.AroundInvokeIn terceptor.intercept(InterceptorManager.java:861)
      at com.sun.ejb.containers.interceptors.AroundInvokeCh ainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.containers.interceptors.InterceptorMan ager.intercept(InterceptorManager.java:370)
      at com.sun.ejb.containers.BaseContainer.__intercept(B aseContainer.java:5360)
      at com.sun.ejb.containers.BaseContainer.intercept(Bas eContainer.java:5348)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 14)
      ... 48 more


      Java Code:
      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      package JSFBean;

      import EntityBean.TblUsers;
      import SessionBean.TblClassesFacade;
      import SessionBean.TblUsersFacade;
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.io.InputStream;
      import java.util.Date;
      import java.util.List;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.ejb.EJB;
      import javax.faces.application.FacesMessage;
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.RequestScoped;
      import javax.faces.context.ExternalContext;
      import javax.faces.context.FacesContext;
      import javax.faces.event.ActionEvent;
      import org.primefaces.event.FileUploadEvent;
      import org.primefaces.model.DefaultStreamedContent;
      import org.primefaces.model.StreamedContent;

      /**
      *
      * @author DucPM
      */
      @ManagedBean
      @RequestScoped
      public class UserBean {

      /**
      * Creates a new instance of UserBean
      */
      public UserBean() {
      }
      @EJB
      TblUsersFacade tuf;
      TblClassesFacade tcf;
      JSFController jc;
      private TblUsers selectedUser;
      private String userName, password, groupName, fullName, gender, address, phone, email, description, status;
      private String filePath, fileSave;
      private int classID;
      private Date birthday, registerDate;
      private static final int BUFFER_SIZE = 6124;
      private StreamedContent avatar;



      public void addUser(ActionEvent e) {
      try {
      TblUsers u = new TblUsers();
      TblUsers uTemp = tuf.find(userName);
      if (uTemp != null) {
      FacesMessage mes = new FacesMessage("Information", "User : " + userName + " already exist!");
      FacesContext.getCurrentInstance().addMessage(null, mes);
      } else {
      u.setUserName(userName);
      u.setEmail(email);
      u.setAddress(address);
      u.setGender(gender);
      u.setGroupName(groupName);
      u.setFullName(fullName);
      u.setPassword("123456789");
      u.setStatus("Enable");
      u.setDescription(description);
      if (!fileSave.equals("")) {
      u.setAvatar(fileSave);
      } else {
      u.setAvatar("img/noimage.jpg");
      }
      tuf.create(u);
      FacesMessage mes = new FacesMessage("Information", "User : " + userName + " added!");
      FacesContext.getCurrentInstance().addMessage(null, mes);
      userName = "";
      fullName = "";
      groupName = "";
      gender = "";
      address = "";
      birthday = null;
      phone = "";
      email = "";
      description = null;
      registerDate = null;
      status = "";
      filePath = "";
      }
      } catch (Exception ex) {
      FacesMessage mes = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Add user : " + userName + " is not successful!");
      FacesContext.getCurrentInstance().addMessage(null, mes);
      }
      }



      public String getFilePath() {
      return filePath;
      }

      public void setFilePath(String filePath) {
      this.filePath = filePath;
      }

      public String getFileSave() {
      return fileSave;
      }

      public void setFileSave(String fileSave) {
      this.fileSave = fileSave;
      }

      public TblUsers getSelectedUser() {
      return selectedUser;
      }

      public void setSelectedUser(TblUsers selectedUser) {
      this.selectedUser = selectedUser;
      }

      public String getUserName() {
      return userName;
      }

      public void setUserName(String userName) {
      this.userName = userName;
      }

      public String getPassword() {
      return password;
      }

      public void setPassword(String password) {
      this.password = password;
      }

      public String getGroupName() {
      return groupName;
      }

      public void setGroupName(String groupName) {
      this.groupName = groupName;
      }

      public String getFullName() {
      return fullName;
      }

      public void setFullName(String fullName) {
      this.fullName = fullName;
      }

      public String getGender() {
      return gender;
      }

      public void setGender(String gender) {
      this.gender = gender;
      }

      public String getAddress() {
      return address;
      }

      public void setAddress(String address) {
      this.address = address;
      }

      public String getPhone() {
      return phone;
      }

      public void setPhone(String phone) {
      this.phone = phone;
      }

      public String getEmail() {
      return email;
      }

      public void setEmail(String email) {
      this.email = email;
      }

      public String getDescription() {
      return description;
      }

      public void setDescription(String description) {
      this.description = description;
      }

      public String getStatus() {
      return status;
      }

      public void setStatus(String status) {
      this.status = status;
      }

      public int getClassID() {
      return classID;
      }

      public void setClassID(int classID) {
      this.classID = classID;
      }

      public Date getBithday() {
      return birthday;
      }

      public void setBithday(Date bithday) {
      this.birthday = bithday;
      }

      public Date getRegisterDate() {
      return registerDate;
      }

      public void setRegisterDate(Date registerDate) {
      this.registerDate = registerDate;
      }

      public StreamedContent getAvatar() {
      return avatar;
      }

      public void setAvatar(StreamedContent avatar) {
      this.avatar = avatar;
      }
      }
      Java Code:
      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      package SessionBean;

      import EntityBean.TblUsers;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      /**
      *
      * @author DucPM
      */
      @Stateless
      public class TblUsersFacade extends AbstractFacade<TblUsers> {
      @PersistenceContext(unitName = "DemoPJPU")
      private EntityManager em;

      @Override
      protected EntityManager getEntityManager() {
      return em;
      }

      public TblUsersFacade() {
      super(TblUsers.class);
      }

      }
      Java Code:
      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      package EntityBean;

      import java.io.Serializable;
      import java.util.Date;
      import java.util.List;
      import javax.persistence.Basic;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.ManyToOne;
      import javax.persistence.NamedQueries;
      import javax.persistence.NamedQuery;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;
      import javax.persistence.Temporal;
      import javax.persistence.TemporalType;
      import javax.validation.constraints.NotNull;
      import javax.validation.constraints.Size;
      import javax.xml.bind.annotation.XmlRootElement;
      import javax.xml.bind.annotation.XmlTransient;

      /**
      *
      * @author DucPM
      */
      @Entity
      @Table(name = "tblUsers")
      @XmlRootElement
      @NamedQueries({
      @NamedQuery(name = "TblUsers.findAll", query = "SELECT t FROM TblUsers t"),
      @NamedQuery(name = "TblUsers.findById", query = "SELECT t FROM TblUsers t WHERE t.id = :id"),
      @NamedQuery(name = "TblUsers.findByUserName", query = "SELECT t FROM TblUsers t WHERE t.userName = :userName"),
      @NamedQuery(name = "TblUsers.findByPassword", query = "SELECT t FROM TblUsers t WHERE t.password = :password"),
      @NamedQuery(name = "TblUsers.findByGroupName", query = "SELECT t FROM TblUsers t WHERE t.groupName = :groupName"),
      @NamedQuery(name = "TblUsers.findByFullName", query = "SELECT t FROM TblUsers t WHERE t.fullName = :fullName"),
      @NamedQuery(name = "TblUsers.findByGender", query = "SELECT t FROM TblUsers t WHERE t.gender = :gender"),
      @NamedQuery(name = "TblUsers.findByAvatar", query = "SELECT t FROM TblUsers t WHERE t.avatar = :avatar"),
      @NamedQuery(name = "TblUsers.findByAddress", query = "SELECT t FROM TblUsers t WHERE t.address = :address"),
      @NamedQuery(name = "TblUsers.findByBirthday", query = "SELECT t FROM TblUsers t WHERE t.birthday = :birthday"),
      @NamedQuery(name = "TblUsers.findByPhone", query = "SELECT t FROM TblUsers t WHERE t.phone = :phone"),
      @NamedQuery(name = "TblUsers.findByEmail", query = "SELECT t FROM TblUsers t WHERE t.email = :email"),
      @NamedQuery(name = "TblUsers.findByRegisterDate", query = "SELECT t FROM TblUsers t WHERE t.registerDate = :registerDate"),
      @NamedQuery(name = "TblUsers.findByLastVisitDate", query = "SELECT t FROM TblUsers t WHERE t.lastVisitDate = :lastVisitDate"),
      @NamedQuery(name = "TblUsers.findByDescription", query = "SELECT t FROM TblUsers t WHERE t.description = :description"),
      @NamedQuery(name = "TblUsers.findByStatus", query = "SELECT t FROM TblUsers t WHERE t.status = :status")})
      public class TblUsers implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Basic(optional = false)
      @NotNull
      @Column(name = "ID")
      private Integer id;
      @Size(max = 50)
      @Column(name = "UserName")
      private String userName;
      @Size(max = 50)
      @Column(name = "Password")
      private String password;
      @Size(max = 20)
      @Column(name = "GroupName")
      private String groupName;
      @Size(max = 50)
      @Column(name = "FullName")
      private String fullName;
      @Size(max = 10)
      @Column(name = "Gender")
      private String gender;
      @Size(max = 200)
      @Column(name = "Avatar")
      private String avatar;
      @Size(max = 50)
      @Column(name = "Address")
      private String address;
      @Column(name = "Birthday")
      @Temporal(TemporalType.TIMESTAMP)
      private Date birthday;
      // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
      @Size(max = 50)
      @Column(name = "Phone")
      private String phone;
      // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
      @Size(max = 50)
      @Column(name = "Email")
      private String email;
      @Column(name = "RegisterDate")
      @Temporal(TemporalType.TIMESTAMP)
      private Date registerDate;
      @Column(name = "LastVisitDate")
      @Temporal(TemporalType.TIMESTAMP)
      private Date lastVisitDate;
      @Size(max = 1073741823)
      @Column(name = "Description")
      private String description;
      @Size(max = 50)
      @Column(name = "Status")
      private String status;
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblUsers")
      private List<TblUserAssignment> tblUserAssignmentList;
      @OneToMany(mappedBy = "staffID")
      private List<TblClasses> tblClassesList;
      @JoinColumn(name = "ClassID", referencedColumnName = "ID")
      @ManyToOne
      private TblClasses classID;
      @OneToMany(mappedBy = "userID")
      private List<TblFeebbacks> tblFeebbacksList;

      public TblUsers() {
      }

      public TblUsers(Integer id) {
      this.id = id;
      }

      public Integer getId() {
      return id;
      }

      public void setId(Integer id) {
      this.id = id;
      }

      public String getUserName() {
      return userName;
      }

      public void setUserName(String userName) {
      this.userName = userName;
      }

      public String getPassword() {
      return password;
      }

      public void setPassword(String password) {
      this.password = password;
      }

      public String getGroupName() {
      return groupName;
      }

      public void setGroupName(String groupName) {
      this.groupName = groupName;
      }

      public String getFullName() {
      return fullName;
      }

      public void setFullName(String fullName) {
      this.fullName = fullName;
      }

      public String getGender() {
      return gender;
      }

      public void setGender(String gender) {
      this.gender = gender;
      }

      public String getAvatar() {
      return avatar;
      }

      public void setAvatar(String avatar) {
      this.avatar = avatar;
      }

      public String getAddress() {
      return address;
      }

      public void setAddress(String address) {
      this.address = address;
      }

      public Date getBirthday() {
      return birthday;
      }

      public void setBirthday(Date birthday) {
      this.birthday = birthday;
      }

      public String getPhone() {
      return phone;
      }

      public void setPhone(String phone) {
      this.phone = phone;
      }

      public String getEmail() {
      return email;
      }

      public void setEmail(String email) {
      this.email = email;
      }

      public Date getRegisterDate() {
      return registerDate;
      }

      public void setRegisterDate(Date registerDate) {
      this.registerDate = registerDate;
      }

      public Date getLastVisitDate() {
      return lastVisitDate;
      }

      public void setLastVisitDate(Date lastVisitDate) {
      this.lastVisitDate = lastVisitDate;
      }

      public String getDescription() {
      return description;
      }

      public void setDescription(String description) {
      this.description = description;
      }

      public String getStatus() {
      return status;
      }

      public void setStatus(String status) {
      this.status = status;
      }

      @XmlTransient
      public List<TblUserAssignment> getTblUserAssignmentList() {
      return tblUserAssignmentList;
      }

      public void setTblUserAssignmentList(List<TblUserAssignment> tblUserAssignmentList) {
      this.tblUserAssignmentList = tblUserAssignmentList;
      }

      @XmlTransient
      public List<TblClasses> getTblClassesList() {
      return tblClassesList;
      }

      public void setTblClassesList(List<TblClasses> tblClassesList) {
      this.tblClassesList = tblClassesList;
      }

      public TblClasses getClassID() {
      return classID;
      }

      public void setClassID(TblClasses classID) {
      this.classID = classID;
      }

      @XmlTransient
      public List<TblFeebbacks> getTblFeebbacksList() {
      return tblFeebbacksList;
      }

      public void setTblFeebbacksList(List<TblFeebbacks> tblFeebbacksList) {
      this.tblFeebbacksList = tblFeebbacksList;
      }

      @Override
      public int hashCode() {
      int hash = 0;
      hash += (id != null ? id.hashCode() : 0);
      return hash;
      }

      @Override
      public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof TblUsers)) {
      return false;
      }
      TblUsers other = (TblUsers) object;
      if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
      return false;
      }
      return true;
      }

      @Override
      public String toString() {
      return "EntityBean.TblUsers[ id=" + id + " ]";
      }

      }
      Java Code:
      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
      <h:head>
      <title>Facelet Title</title>
      </h:head>
      <h:body>
      <h:form id="form">
      <h2 style="text-align: center ; color: #036fab">Add New User</h2>
      <table width="586px">
      <tr>
      <td class="columnleft">Group :</td>
      <td><h:selectOneMenu value="#{userBean.groupName}" style="width: 170px">
      <f:selectItem itemLabel="Administrator" itemValue="Admin"/>
      <f:selectItem itemLabel="Staff/Teacher" itemValue="Staff"/>
      <f:selectItem itemLabel="Student/User" itemValue="Student"/>
      </h:selectOneMenu></td>
      <td rowspan="5" style="text-align: left; vertical-align: top">
      <p:graphicImage value="#{userBean.filePath}" width="150" height="150" id="avatar"></p:graphicImage>

      Image size: 150 x 150(px)
      </td>
      </tr>
      <tr>
      <td class="columnleft">Full-Name :</td>
      <td><p:inputText value="#{userBean.fullName}" maxlength="50" required="true" requiredMessage="Enter Full-Name"/>
      </td>
      </tr>
      <tr>
      <td class="columnleft">Username :</td>
      <td><p:inputText value="#{userBean.userName}" maxlength="20" required="true" requiredMessage="User is not empty." validatorMessage="Username is not valid.">
      <f:validateRegex pattern="[\w]*[a-zA-Z0-9_]"/>
      </p:inputText>
      </td>
      </tr>
      <tr>
      <td class="columnleft">Password:</td>
      <td> Default is <span style="color: red">123456789</span></td>
      </tr>
      <tr>
      <td class="columnleft">Gender :</td>
      <td><h:selectOneMenu value="#{userBean.gender}">
      <f:selectItem itemLabel="Male" itemValue="Male"/>
      <f:selectItem itemLabel="Female" itemValue="Female"/>
      </h:selectOneMenu></td>
      </tr>
      <tr>
      <td class="columnleft">Address:</td>
      <td><p:inputText value="#{userBean.address}"/></td>
      <td></td>
      </tr>
      <tr>
      <td class="columnleft">Birthday :</td>
      <td><p:calendar mindate="1/1/50" navigator="true" value="#{userBean.bithday}"/></td>
      <td></td>
      </tr>
      <tr>
      <td class="columnleft">Phone :</td>
      <td><p:inputText value="#{userBean.phone}" maxlength="50"/></td>
      <td></td>
      </tr>
      <tr>
      <td class="columnleft">Email :</td>
      <td><p:inputText value="#{userBean.email}"
      required="true" requiredMessage="Email is not empty."
      validatorMessage="Email is not valid." maxlength="100">
      <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"/>
      </p:inputText>
      </td>
      <td></td>
      </tr>
      <tr>
      <td class="columnleft">Description :</td>
      <td class="columnright" colspan="2"><p:inputTextarea value="#{userBean.description}" rows="2" cols="40" validatorMessage="Description is greater than allowable maximum of 200 char.">
      <f:validateLength maximum="200"/>
      </p:inputTextarea></td>
      </tr>
      <tr>
      <td class="columnleft">Avatar :</td>
      <td colspan="2" style="width: 300px">
      <p:fileUpload fileUploadListener="#{userBean.handleAvatarUpload(event)}"
      mode="advanced"
      update="growl,avatar"
      sizeLimit="1073741824"
      allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
      </td>
      </tr>
      <tr>
      <p:growl id="growl" showSummary="true" showDetail="true" />
      <td></td>
      <td class="columnleft"><p:commandButton icon="ui-icon-check" ajax="false" value="Create" update="growl" actionListener="#{userBean.addUser(e)}"/></td>
      <td></td>
      </tr>
      </table>
      </h:form>
      </h:body>
      </html>