habuma / spring-in-action-5-samples

Home for example code from Spring in Action 5.
Apache License 2.0
1.21k stars 1.04k forks source link

Chapter 2 validation problems #34

Open noname41 opened 5 years ago

noname41 commented 5 years ago

when you validate design template, in case of errors(empty(<5 signs) name, not important whether checkboxes are marked or not), post method return "design" without ingredients info and so the page loaded incorrect (empty fields instead input checkboxes); field name on other hand validates correctly. model in get {order=Order(id=null, placedAt=null, deliveryName=null, deliveryStreet=null, deliveryCity=null, deliveryState=null, deliveryZip=null, ccNumber=null, ccExpiration=null, ccCVV=null, tacos=[]), taco=Taco(id=null, createdAt=null, name=null, ingredients=null), wrap=[Ingredient(id=FLTO, name=Flour Tortilla, type=WRAP), Ingredient(id=COTO, name=Corn Tortilla, type=WRAP)], protein=[Ingredient(id=GRBF, name=Ground Beef, type=PROTEIN), Ingredient(id=CARN, name=Carnitas, type=PROTEIN)], veggies=[Ingredient(id=TMTO, name=Diced Tomatoes, type=VEGGIES), Ingredient(id=LETC, name=Lettuce, type=VEGGIES)], cheese=[Ingredient(id=CHED, name=Cheddar, type=CHEESE), Ingredient(id=JACK, name=Monterrey Jack, type=CHEESE)], sauce=[Ingredient(id=SLSA, name=Salsa, type=SAUCE), Ingredient(id=SRCR, name=Sour Cream, type=SAUCE)]} model in post Taco(id=null, createdAt=null, name=, ingredients=[Ingredient(id=CARN, name=Carnitas, type=PROTEIN)])

why it's happend?? It seems like "taco" thymeleaf object is only returned, losing the rest info err1

ps: if name>5 sign, occurs NullPointerException.

Eslem commented 5 years ago

Hi, i think that the error comes because the model that you return is different so doesn't have all the ingredients. They have changed it in the InPrint tag https://github.com/habuma/spring-in-action-5-samples/blob/v1.0-InPrint/ch02/tacos/src/main/java/tacos/web/DesignTacoController.java

olegkamuz commented 4 years ago

Some more thoughts on same problem https://github.com/habuma/spring-in-action-5-samples/issues/78

GOODXIONG commented 4 years ago

Hi, i think that the error comes because the model that you return is different so doesn't have all the ingredients. They have changed it in the InPrint tag https://github.com/habuma/spring-in-action-5-samples/blob/v1.0-InPrint/ch02/tacos/src/main/java/tacos/web/DesignTacoController.java

It work! But how can I do it in chapter 3,the problem still exists.