Browse Source

Set fallback message key strings for author & category NULL values

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.2-alpha
Pekka Helenius 4 years ago
parent
commit
659cfe791e
4 changed files with 18 additions and 5 deletions
  1. +3
    -0
      bookstore/src/main/resources/messages.properties
  2. +4
    -1
      bookstore/src/main/resources/templates/bookadd.html
  3. +4
    -1
      bookstore/src/main/resources/templates/bookedit.html
  4. +7
    -3
      bookstore/src/main/resources/templates/booklist.html

+ 3
- 0
bookstore/src/main/resources/messages.properties View File

@ -39,6 +39,9 @@ book.error.year = Invalid year
book.error.price = Invalid price book.error.price = Invalid price
book.error.isbn.exists = ISBN code already exists book.error.isbn.exists = ISBN code already exists
book.error.id.invalid = Wrong book book.error.id.invalid = Wrong book
book.null.author = Unknown
book.null.category = None
page.title.browser.list = Bookstore page page.title.browser.list = Bookstore page
page.title.browser.add = Add book page.title.browser.add = Add book


+ 4
- 1
bookstore/src/main/resources/templates/bookadd.html View File

@ -204,7 +204,10 @@
th:value="${category.id}" th:value="${category.id}"
th:text="${category.name}" th:text="${category.name}"
>(obj) category.name</option> >(obj) category.name</option>
<option value="">None</option>
<option value=""
th:text="${#messages.msgOrNull('book.null.category')} ?: 'book.null.category'">
book.null.category
</option>
</select> </select>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.category')} ?: 'book.desc.set.category'"> th:text="${#messages.msgOrNull('book.desc.set.category')} ?: 'book.desc.set.category'">


+ 4
- 1
bookstore/src/main/resources/templates/bookedit.html View File

@ -204,7 +204,10 @@
th:value="${category.id}" th:value="${category.id}"
th:text="${category.name}" th:text="${category.name}"
>(obj) category.name</option> >(obj) category.name</option>
<option value="">None</option>
<option value=""
th:text="${#messages.msgOrNull('book.null.category')} ?: 'book.null.category'">
book.null.category
</option>
</select> </select>
<small class="form-text text-muted" <small class="form-text text-muted"


+ 7
- 3
bookstore/src/main/resources/templates/booklist.html View File

@ -45,15 +45,19 @@
| Set author last name | Set author last name
| else: | else:
| Set empty string for last name | Set empty string for last name
##########
else: else:
Author is 'Unknown'
|-> Check if book.null.author exists. If yes, then:
| Get value from book.null.author message key
| else:
| Author is string value 'book.null.author'
*/--> */-->
<td th:text="${book.author != null} ? ( (${book.author.firstName != null} ? (${book.author.firstName} + ' ') : '') + (${book.author.lastName != null} ? ${book.author.lastName} : '') ) : 'Unknown'">(obj) book.author.firstName (obj) book.author.lastName</td>
<td th:text="${book.author != null} ? ( (${book.author.firstName != null} ? (${book.author.firstName} + ' ') : '') + (${book.author.lastName != null} ? ${book.author.lastName} : '') ) : (${#messages.msgOrNull('book.null.author')} ?: 'book.null.author')">(obj) book.author.firstName (obj) book.author.lastName</td>
<td th:text="${book.title}">(obj) book.title</td> <td th:text="${book.title}">(obj) book.title</td>
<td th:text="${book.isbn}">(obj) book.isbn</td> <td th:text="${book.isbn}">(obj) book.isbn</td>
<td th:text="${book.year}">(obj) book.year</td> <td th:text="${book.year}">(obj) book.year</td>
<td th:text="${book.category != null} ? ${book.category.name} : 'None'">(obj) book.category.name</td>
<td th:text="${book.category != null} ? ${book.category.name} : (${#messages.msgOrNull('book.null.category')} ?: 'book.null.category')">(obj) book.category.name</td>
<td th:text="(${#numbers.formatDecimal(book.price, 1, 2)} ?: '0.00') + ' ' + (${#messages.msgOrNull('page.symbols.currency')} ?: 'page.symbols.currency')"> <td th:text="(${#numbers.formatDecimal(book.price, 1, 2)} ?: '0.00') + ' ' + (${#messages.msgOrNull('page.symbols.currency')} ?: 'page.symbols.currency')">
0.00 page.symbols.currency 0.00 page.symbols.currency
</td> </td>


Loading…
Cancel
Save