Beispiel #1
0
 /** 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";
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
 /** 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();
   }
 }