@PostConstruct public void init() { username = FacesContext.getCurrentInstance() .getExternalContext() .getSessionMap() .get("username") .toString(); options.add("Available"); options.add("Not Available"); business = (Business) commonEJB.getSingleInfo( "select b from Business b where b.username = '******'"); imageLogo = business.getBusinessLogo().toString().trim(); }
public void changePassword() { RequestContext context = RequestContext.getCurrentInstance(); Business b = (Business) commonEJB.getSingleInfo( "select b from Business b where b.username = '******'"); if (b.getPassword().toString().trim().equals(oldPassword.trim())) { b.setPassword(newPassword); boolean checkChangePass = commonEJB.updateData(b); if (checkChangePass == true) { showMessage("Success", "Password has changed successful", "info"); } else { showMessage("Fail", "Cannot persist to database", "error"); } context.addCallbackParam("changedPass", "yes"); } else { showMessage("Old password is incorrect", null, "error"); context.addCallbackParam("changedPass", ""); } }