Los shows funcionan pero hay un error con las TimeOffer, parece que los

jsp no reconocen el tipo LocalTime
This commit is contained in:
Antonio Vidal 2021-03-25 18:00:19 +01:00
parent 5a55aa8084
commit 88b304f72a
5 changed files with 197 additions and 1 deletions

View file

@ -0,0 +1,67 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cheapy.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.cheapy.model.FoodOffer;
import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.FoodOfferService;
import org.springframework.cheapy.service.NuOfferService;
import org.springframework.cheapy.service.SpeedOfferService;
import org.springframework.cheapy.service.TimeOfferService;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
* @author Michael Isvy
*/
@Controller
public class FoodOfferController {
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
private final FoodOfferService foodOfferService;
public FoodOfferController(final FoodOfferService foodOfferService) {
this.foodOfferService = foodOfferService;
}
@GetMapping("/offers/food/{foodOfferId}")
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
FoodOffer foodOffer=this.foodOfferService.findFoodOfferById(foodOfferId);
model.put("foodOffer", foodOffer);
return "foodOffers/foodOffersShow";
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cheapy.web;
import java.util.Map;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.TimeOfferService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
* @author Michael Isvy
*/
@Controller
public class TimeOfferController {
//private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
private final TimeOfferService timeOfferService;
public TimeOfferController(final TimeOfferService timeOfferService) {
this.timeOfferService = timeOfferService;
}
@GetMapping("/offers/time/{timeOfferId}")
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId);
model.put("timeOffer", timeOffer);
return "timeOffers/timeOffersShow";
}
}

View file

@ -0,0 +1,44 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<cheapy:layout pageName="foodOffer">
<h2>Oferta por plato específico</h2>
<table class="table table-striped">
<tr>
<th>Inicio de la oferta</th>
<td><b><c:out value="${foodOffer.start}"/></b></td>
</tr>
<tr>
<th>Fin de la oferta</th>
<td><c:out value="${foodOffer.end}"/></td>
</tr>
<tr>
<th>Plato en oferta</th>
<td><c:out value="${foodOffer.food}"/></td>
</tr>
<tr>
<th>Descuento</th>
<td><c:out value="${foodOffer.discount}"/></td>
</tr>
<tr>
<th>Cantidad</th>
<td><c:out value="${foodOffer.units}"/></td>
</tr>
<tr>
<th>Codigo de la oferta</th>
<td><c:out value="${foodOffer.code}"/></td>
</tr>
</table>
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
</cheapy:layout>

View file

@ -4,7 +4,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<cheapy:layout pageName="timeOffer">
<cheapy:layout pageName="nuOffer">
<h2>Oferta por número de comensales</h2>

View file

@ -0,0 +1,31 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<cheapy:layout pageName="timeOffer">
<h2>Oferta por franja horária</h2>
<table class="table table-striped">
<tr>
<th>Inicio de la oferta</th>
<td><b><c:out value="${timeOffer.start}"/></b></td>
</tr>
<tr>
<th>Fin de la oferta</th>
<td><c:out value="${timeOffer.end}"/></td>
</tr>
<tr>
<th>Descuento</th>
<td><c:out value="${timeOffer.discount}"/></td>
</tr>
<tr>
<th>Codigo de la oferta</th>
<td><c:out value="${timeOffer.code}"/></td>
</tr>
</table>
</cheapy:layout>