/** JSF method to delete the selected product. */ public String delete() { try { ProductManager.delete(selected); } catch (ProductException e) { // TODO Auto-generated catch block e.printStackTrace(); } return "/secure/admin/product_list?faces-redirect=true"; }
/** * JSF method to provide access to all products. * * @return a list of products */ public List<Product> getAll() { List<Product> all = null; try { all = ProductManager.findAllProducts(); } catch (ProductException e) { // TODO Auto-generated catch block e.printStackTrace(); } return all; }
/** Bean initialisation. */ @PostConstruct public void init() { try { // Load the selected item, if an ID is passed as a query parameter FacesContext fc = FacesContext.getCurrentInstance(); String uuid = fc.getExternalContext().getRequestParameterMap().get("uuid"); if (uuid != null && !uuid.isEmpty()) { selected = ProductManager.findByUuid(uuid); editing = true; } else { selected = new Product(); } // Must have as least one variant if (selected.getVariants().size() == 0) { addVariant(); } } catch (ProductException e) { // TODO Auto-generated catch block e.printStackTrace(); } }