}
public FormSubmission processEditProductRequest() {
FormSubmission fs = new FormSubmission();
Long id = Long.parseLong(req.getParameter(Parameters.PRODUCT_ID.getId()));
l.info("edit product "+id);
Product p = service.getById(id);
try {
String action = req.getParameter(Parameters.PRODUCT_ACTION.getId());
if (action.equals("Update Product")) {
Double price = Double.parseDouble(req.getParameter(Parameters.PRODUCT_PRICE.getId()));
p.setPrice(price);
String description = req.getParameter(Parameters.PRODUCT_DESC.getId());
p.setDescription(description);
String onSale = req.getParameter(Parameters.ON_SALE.getId());
if (onSale != null && onSale.equals("on")) {
p.setSaleInd("T");
}
else {
p.setSaleInd("F");
}
String active = req.getParameter(Parameters.ON_SALE.getId());
p.setActive(active != null && active.equals("on"));
fs.setForm(FormName.EDIT_PRODUCT);
}
else if (action.equals("")) {
}
fs.setResultMessage("Update sucessful!");
service.store(p);
} catch (Exception e) {
l.log(Level.WARNING, "Error updating product", e);
fs.setResultMessage(e.getMessage());
}
View fv = getProductView(true, p);
fs.setResultView(fv);
return fs;
}