public void cancelEditBusiness() { if (!imageLogo.equalsIgnoreCase(business.getBusinessLogo().toString().trim())) { boolean checkImage = upload.deleteImage(imageLogo); if (checkImage == true) { imageLogo = business.getBusinessLogo().toString().trim(); } } }
public void editBusinessInformation() { RequestContext context = RequestContext.getCurrentInstance(); boolean checkImage = true; if (!imageLogo.equalsIgnoreCase(business.getBusinessLogo().toString().trim())) { checkImage = upload.deleteImage(business.getBusinessLogo().toString().trim()); business.setBusinessLogo(imageLogo); } boolean checkUpdate = commonEJB.updateData(business); if (checkUpdate == true) { showMessage("Success", "Information details have changed successful", "info"); context.addCallbackParam("editBusiness", "yes"); } else { showMessage("Fail", "Cannot persist to database", "error"); context.addCallbackParam("editBusiness", ""); } }
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", ""); } }
public void uploadImage(FileUploadEvent event) throws IOException { boolean checkImage = true; if (business.getBusinessLogo() != null) { if (!imageLogo.equalsIgnoreCase(business.getBusinessLogo().toString().trim())) { checkImage = upload.deleteImage(imageLogo); } } else { if (!imageLogo.equalsIgnoreCase("")) { checkImage = upload.deleteImage(imageLogo); } } if (checkImage == true) { String fileName = event.getFile().getFileName(); boolean checkExtension = upload.checkExtension(fileName); if (checkExtension == true) { imageLogo = upload.copyImage(fileName, event.getFile().getInputstream(), "logo"); } } else { showMessage("Error Message", "Cannot upload image", "error"); } }
@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(); }