coffee_fan (27) [Avatar] Offline
#1
It is not hard to create it, but for folks that are following along it is one annoyance.
v8 (6) [Avatar] Offline
#2
filterByType method is included in the DesignTacoController source code.
I assume the author didn't include it in the listing as it brings no value for the understanding of the concepts.

	private List<Ingredient> filterByType(List<Ingredient> ingredients, Type type) {
		
		return ingredients.stream()
				.filter(x -> x.getType().equals(type))
				.collect(Collectors.toList());
		
	}
habuma (279) [Avatar] Offline
#3
That's right...I left it out of the manuscript because it didn't pertain directly to the subject. It's fairly brief, so I guess I could consider working it in. But for space reasons and subject-focus reasons, I can't practically include *ALL* of the code in the book.
190896 (15) [Avatar] Offline
#4
Agree, I would put it in the book. There's nothing worse than following along and then finding it doesn't compile.
johannkokos (4) [Avatar] Offline
#5
I hope the author mentioned the the function could be found in the source code. A simple note is enough.
409563 (4) [Avatar] Offline
#6
Also these in the same listing:

- `package tacos.web;` should be `package tacos;`
- `import tacos.Taco;` this import cannot be resolved.
CounterClockWise (2) [Avatar] Offline
#7
Listing 2.2 refers to the class Taco; I have not found Taco.java in the pdf, the web site, or the downloaded source code. I created a dummy Taco class (and the filterByType method) to get listing 2.2 to compile.

But then I had trouble running the code; I kept getting obscure Thymeleaf errors when trying to access http://localhost:8080/design. I ended up commenting out these two blocks from Listing 2.3/design.html:

<!--
<span class="validationError"
th:if="${#fields.hasErrors('ingredients')}"
th:errors="*{ingredients}">Ingredient Error</span>
-->
...
<!--
<input type="text" th:field="*{name}"/>
-->
<!--end::all[] -->
<!--
<span class="validationError"
th:if="${#fields.hasErrors('name')}"
th:errors="*{name}">Name Error</span>
-->

I don't know enough about Spring 5 and Thymeleaf to know whether these go away when Taco.java has the right contents. It is slowing down my learning journey.