diff --git a/code/exercise_003_qute_products/README.md b/code/exercise_003_qute_products/README.md index baf4abb..15ec1f9 100644 --- a/code/exercise_003_qute_products/README.md +++ b/code/exercise_003_qute_products/README.md @@ -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: @@ -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 ` + - 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 ` + - 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. diff --git a/code/exercise_003_qute_products/src/main/resources/templates/catalogue.html b/code/exercise_003_qute_products/src/main/resources/templates/catalogue.html index e69de29..b6e6441 100644 --- a/code/exercise_003_qute_products/src/main/resources/templates/catalogue.html +++ b/code/exercise_003_qute_products/src/main/resources/templates/catalogue.html @@ -0,0 +1,15 @@ + + + Welcome to the HIQUEA catalog! + + +

HIQUEA Catalog

+

Total products: 3

+

Products

+ + + \ No newline at end of file diff --git a/code/exercise_003_qute_products/src/main/resources/templates/details.html b/code/exercise_003_qute_products/src/main/resources/templates/details.html index e69de29..2ef90e8 100644 --- a/code/exercise_003_qute_products/src/main/resources/templates/details.html +++ b/code/exercise_003_qute_products/src/main/resources/templates/details.html @@ -0,0 +1,16 @@ + + + Chair - Details + + +

Chair

+
+
Product ID
+
1
+
Description
+
A metal frame chair, with oak seat
+
Price
+
€ 59.95
+
+ + \ No newline at end of file