public void register(ActionEvent actionEvent) { CustomerDAO cdao = HibernateDAOFactory.instance().getCustomerDAO(); RequestContext context = RequestContext.getCurrentInstance(); FacesMessage msg = null; boolean loggedIn = false; FacesContext fc = FacesContext.getCurrentInstance(); ExternalContext ec = fc.getExternalContext(); if (cdao.checklemail(email)) { Customer cs = new Customer(); cs.setEmail(email); cs.setPass(pass); cs.setFullName(fullName); cs.setAddress(address); cs.setPhone(phone); cs.setVip(vip); cdao.add(cs); loggedIn = true; msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Registe succes! Welcome", email); String url = "index.xhtml"; try { ec.redirect(url); } catch (IOException ex) { } } else { loggedIn = false; msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Registe Error", "Invalid credentials"); } FacesContext.getCurrentInstance().addMessage(null, msg); context.addCallbackParam("loggedIn", loggedIn); }
public String createStyle() { FacesContext c = FacesContext.getCurrentInstance(); String fileType = UploadUtil.checkFileType(imageFile, "jpg,gif,png"); if (imageFile != null && fileType == null) { c.addMessage(null, new FacesMessage("File not accpected", "Not image file")); return "style_create"; } else { String realPatch = ((ServletContext) c.getExternalContext().getContext()).getRealPath("/"); StyleDAO sDao = HibernateDAOFactory.instance().getStyleDAO(); sDao.add(style); style.setImage("resources/upload/styles/" + style.getStyleId() + "." + fileType); sDao.update(style); UploadUtil.saveUploadFile( imageFile, realPatch + "/resources/upload/styles", style.getStyleId() + "." + fileType); return "style_view"; } }
public Restaurantbean() { RestaurantDAO dao = HibernateDAOFactory.instance().getRestaurantDAO(); list = dao.findAll(); }