<%-- * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. --%> <%-- ==================================================================== --%> <%-- Executes a query which is determined by the request parameter. --%> <%-- Displays the results --%> <%-- ==================================================================== --%> <%@include file="header.jsp"%> <%@page import="openbook.server.OpenBookService"%> <%@page import="openbook.domain.Book"%> <%@page import="openbook.domain.Author"%> <%@page import="openbook.util.JSPUtility"%> <%@page import="java.util.List"%>

Query Result

This page is displaying the result of the Criteria query specified in the previous Search page.
<%! /** * Concatenates the names of the given list of Authors. * */ public static String namesOf(List authors) { StringBuilder names = new StringBuilder(); if (authors == null) return names.toString(); for (Author a : authors) { if (names.length() != 0) names.append(", "); names.append(a.getName()); } return names.toString(); } %> <% OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE); if (service == null) { %> <% } %> <% String title = request.getParameter(FORM_TITLE); Double minPrice = JSPUtility.toDouble(request.getParameter(FORM_PRICE_MIN)); Double maxPrice = JSPUtility.toDouble(request.getParameter(FORM_PRICE_MAX)); String author = request.getParameter(FORM_AUTHOR); List books = service.select(title, minPrice, maxPrice, author); String query = service.getQuery(title, minPrice, maxPrice, author); %> Query : <%= query %>

<% if (books.isEmpty()) { %> did not select any book.

Search again

<% return; } %>
<% int i = 0; for (Book book : books) { session.setAttribute(book.getISBN(), book); %> <% } %>
Selected <%= books.size() %> Book<%= books.size() == 1 ? "" : "s" %>
ISBN Title Price Authors Add to Cart
<%= book.getISBN() %> <%= book.getTitle() %> <%= JSPUtility.format(book.getPrice()) %> <%= namesOf(book.getAuthors()) %>

<%@include file="footer.jsp"%>