Package oss.ngocminh.lego.persistence

Examples of oss.ngocminh.lego.persistence.ProductDAO


  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    try {
      Connection conn = getConnection();
      ProductDAO productDAO = new ProductDAO(conn);
      int productId = Integer.parseInt(req.getParameter("product"));
      Entity product = productDAO.findById(productId);
      productDAO.fetchImage(product);
      int quantity = Integer.parseInt(req.getParameter("quantity"));
      conn.close();
     
      List<Entity> orders = (List<Entity>) req.getSession().getAttribute("orders");
      if (orders == null) {
View Full Code Here


   */
  protected void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    try {
      Connection conn = getConnection();
      ProductDAO productDAO = new ProductDAO(conn);
      ProductType type = ProductType.valueOf(request.getParameter("type"));
      List<Entity> products = productDAO.findByType(type.name());
      productDAO.fetchImage(products);
      conn.close();
     
      request.setAttribute("type", type);
      request.setAttribute("products", products);
      renderView(request, response);
View Full Code Here

      CategoryDAO categoryDAO = new CategoryDAO();
      categoryDAO.setConnection(conn);
      List<Entity> categories = categoryDAO.list();
      request.setAttribute("categories", categories);
     
      ProductDAO productDAO = new ProductDAO();
      productDAO.setConnection(conn);
      List<Entity> bestSellers = productDAO.findRecentBestSellers(20);
      request.setAttribute("bestSellers", bestSellers);
     
      renderView(request, response);
    } catch (SQLException e) {
      throw new ServletException(e);
View Full Code Here

    super();
  }
 
  @Override
  public void init() throws ServletException {
    productDAO = new ProductDAO();
  }
View Full Code Here

    public ProductViewController() {
    }

    @Override
    public void init() throws ServletException {
      productDAO = new ProductDAO();
      imageDAO = new ImageDAO();
    }
View Full Code Here

    return "products.xml";
  }

  @Test
  public void testList() throws SQLException {
    ProductDAO productDAO = new ProductDAO();
    productDAO.setConnection(getSqlConnection());
    List<Entity> entities = productDAO.list();
    Assert.assertEquals(3, entities.size());
  }
View Full Code Here

TOP

Related Classes of oss.ngocminh.lego.persistence.ProductDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.