Package com.sun.bookstore.database

Examples of com.sun.bookstore.database.Book


    /**
     * <p>Add the displayed item to our shopping cart.</p>
     */
    public String add() {
        Book book = selected();
        cart()
            .add(
            book.getBookId(),
            book);
        message(
            null,
            "ConfirmAdd",
            new Object[] { book.getTitle() });

        return ("catalog");
    }
View Full Code Here


    public void doGet(
        HttpServletRequest request,
        HttpServletResponse response) {
        String bookId = null;
        Book book = null;
        String clear = null;
        BookDBAO bookDBAO = (BookDBAO) getServletContext()
                                           .getAttribute("bookDBAO");
        HttpSession session = request.getSession();
        String selectedScreen = request.getServletPath();
        ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");

        if (cart == null) {
            cart = new ShoppingCart();
            session.setAttribute("cart", cart);
        }

        if (selectedScreen.equals("/bookcatalog")) {
            bookId = request.getParameter("Add");

            if (!bookId.equals("")) {
                try {
                    book = bookDBAO.getBook(bookId);

                    if (book.getOnSale()) {
                        double sale = book.getPrice() * .85;
                        Float salePrice = new Float(sale);
                        book.setPrice(salePrice.floatValue());
                    }

                    cart.add(bookId, book);
                } catch (BookNotFoundException ex) {
                    // not possible
View Full Code Here

    /**
     * <p>Add the selected item to our shopping cart.</p>
     */
    public String add() {
        Book book = book();
        cart()
            .add(
            book.getBookId(),
            book);
        message(
            null,
            "ConfirmAdd",
            new Object[] { book.getTitle() });

        return ("catalog");
    }
View Full Code Here

        this.totalBooks = totalBooks;
    }

    public int getBookQuantity() {
        int bookQuantity = 0;
        Book book = book();

        if (book == null) {
            return bookQuantity;
        }

        List<ShoppingCartItem> results = cart()
                                             .getItems();

        for (Iterator items = results.iterator(); items.hasNext();) {
            ShoppingCartItem item = (ShoppingCartItem) items.next();
            Book bd = (Book) item.getItem();

            if ((bd.getBookId()).equals(book.getBookId())) {
                bookQuantity = item.getQuantity();

                break;
            }
        }
View Full Code Here

    /**
     * <p>Add the selected item to our shopping cart.</p>
     */
    public String add() {
        Book book = book();
        cart()
            .add(
            book.getBookId(),
            book);
        message(
            null,
            "ConfirmAdd",
            new Object[] { book.getTitle() });

        return ("catalog");
    }
View Full Code Here

        this.totalBooks = totalBooks;
    }

    public int getBookQuantity() {
        int bookQuantity = 0;
        Book book = book();

        if (book == null) {
            return bookQuantity;
        }

        List<ShoppingCartItem> results = cart()
                                             .getItems();

        for (Iterator items = results.iterator(); items.hasNext();) {
            ShoppingCartItem item = (ShoppingCartItem) items.next();
            Book bd = (Book) item.getItem();

            if ((bd.getBookId()).equals(book.getBookId())) {
                bookQuantity = item.getQuantity();

                break;
            }
        }
View Full Code Here

            Iterator i = cart.getItems()
                             .iterator();

            while (i.hasNext()) {
                ShoppingCartItem item = (ShoppingCartItem) i.next();
                Book book = (Book) item.getItem();
                writer.print("ISBN: " + book.getBookId());
                writer.print("   Title: " + book.getTitle());
                writer.print("   Quantity: " + item.getQuantity());
                writer.println();
            }
        }
View Full Code Here

            Iterator i = cart.getItems()
                             .iterator();

            while (i.hasNext()) {
                ShoppingCartItem item = (ShoppingCartItem) i.next();
                Book book = (Book) item.getItem();
                writer.print("ISBN: " + book.getBookId());
                writer.print("   Title: " + book.getTitle());
                writer.print("   Quantity: " + item.getQuantity());
                writer.println();
            }
        }
View Full Code Here

        if (dispatcher != null) {
            dispatcher.include(request, response);
        }

        try {
            Book bd = bookDB.getBook("203");

            //Left cell -- the "book of choice"
            out.println(
                    "<b>" + messages.getString("What") + "</b>" + "<p>"
                    + "<blockquote>" + "<em><a href=\""
                    + response.encodeURL(
                            request.getContextPath()
                            + "/bookdetails?bookId=203") + "\">"
                    + bd.getTitle() + "</a></em>" + messages.getString("Talk")
                    + "</blockquote>");

            //Right cell -- various navigation options
            out.println(
                    "<p><a href=\""
View Full Code Here

        String bookId = request.getParameter("bookId");

        if (bookId != null) {
            // and the information about the book
            try {
                Book bd = bookDB.getBook(bookId);
                Currency c = (Currency) session.getAttribute("currency");

                if (c == null) {
                    c = new Currency();
                    c.setLocale(request.getLocale());
                    session.setAttribute("currency", c);
                }

                c.setAmount(bd.getPrice());

                //Print out the information obtained
                out.println(
                        "<h2>" + bd.getTitle() + "</h2>" + "&nbsp;"
                        + messages.getString("By") + " <em>"
                        + bd.getFirstName() + " " + bd.getSurname()
                        + "</em> &nbsp; &nbsp; " + "(" + bd.getCalendar_year()
                        + ")<br> &nbsp; <br>" + "<h4>"
                        + messages.getString("Critics") + "</h4>"
                        + "<blockquote>" + bd.getDescription()
                        + "</blockquote>" + "<h4>"
                        + messages.getString("Price") + c.getFormat() + "</h4>"
                        + "<p><strong><a href=\""
                        + response.encodeURL(
                                request.getContextPath()
View Full Code Here

TOP

Related Classes of com.sun.bookstore.database.Book

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.