Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions code/exercise_003_qute_products/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Exercise 3: Qute Products
## Exercise 4: Even Quter Products

In this exercise, we will start on the HIQUEA catalogue. We will make two pages, a page that lists all products, and a page that shows the details of a product.
In this exercise, we will use some more Qute features to make some parts of our templates reusable. You will probably need the Qute Reference Documentation to figure out how to do these things.

* Create a class `Product`, with the following *public final* fields, and *a suitable constructor*:
- Long id
- String name
- String description
- BigDecimal price
- Long id
- String name
- String description
- BigDecimal price

* Pull in a file `Products.java` by executing the following command in a terminal:

Expand All @@ -16,22 +16,25 @@ In this exercise, we will start on the HIQUEA catalogue. We will make two pages,

* In this class, create a `products` endpoint, that shows an HTML page with all
products (use the products from the `all()` method on the `Products` class).
You can use the HTML from the file `materials/exercise-3/catalogue.html`.
Make sure to replace the following with Qute expressions:
Pull in a `catalogue.html` template by executing the following command in a terminal :
- `cmtc pull-template src/main/resources/templates/catalogue.html <root folder of exercise repo>`
- Make sure to replace the following with Qute expressions:
- Product names
- Path parameters in URLs
- Total number of products

* In the same class, create a `products/{productId}` endpoint, that lists the
details of a product (use the `getById` method on the `Products` class).
You can use the HTML from the file `materials/exercise-3/details.html`.
Make sure to replace the following with Qute expressions:
* Pull in a `details.html` template by executing the following command in a terminal :
- `cmtc pull-template src/main/resources/templates/details.html <root folder of exercise repo>`
- Make sure to replace the following with Qute expressions:
- Product name (twice)
- Product ID
- Description
- Price


* Extra: How would you deal with products that can’t be found?

* Extra: Write a test for both endpoints, testing that they give a `200` response, and contain some strings that should be there.

* Extra: Write a test for both endpoints, testing that they give a `200` response, and contain some strings that should be there.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html lang="en">
<head>
<title>Welcome to the HIQUEA catalog!</title>
</head>
<body>
<h1>HIQUEA Catalog</h1>
<p>Total products: 3</p>
<h2>Products</h2>
<ul>
<li><a href="/products/1">Product 1</a></li>
<li><a href="/products/2">Product 2</a></li>
<li><a href="/products/3">Product 3</a></li>
</ul>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html lang="en">
<head>
<title>Chair - Details</title>
</head>
<body>
<h1>Chair</h1>
<dl>
<dt>Product ID</dt>
<dd>1</dd>
<dt>Description</dt>
<dd>A metal frame chair, with oak seat</dd>
<dt>Price</dt>
<dd>&euro; 59.95</dd>
</dl>
</body>
</html>
Loading