// ---TODO: This feels like a kludge. Find a better way to handle it. public void respondToEditForm(HttpServletRequest request, HttpSession session) { String pid = request.getParameter("productid"); if (pid != null) { try { int product_id = Integer.parseInt(pid); Product prod = Product.loadProduct(new Integer(product_id)); if (prod == null) { Util.noteError( session, "Internal error: No product with ID " + product_id + " was found."); } else { setProduct(prod); } } catch (NumberFormatException e) { Util.noteError(session, "Internal error: Illegal productid: " + pid); } } super.respondToEditForm(request, session); Debug.println("Version.respondToEditForm: Setting 'record' to " + getProduct()); session.setAttribute("record", getProduct()); }
/** @see DatabaseRecord#initializeNewRecord */ public void initializeNewRecord(HttpServletRequest request, HttpSession session) { int product_id = Util.parseInt(Util.getRequiredField(request, session, "productid"), 0); if (product_id != 0) { setProduct(Product.loadProduct(new Integer(product_id))); } }