mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-24 00:05:48 +00:00
Añadir jsp
This commit is contained in:
parent
a75a5adc70
commit
dbf0b01744
7 changed files with 158 additions and 20 deletions
|
@ -25,6 +25,7 @@ import javax.validation.Valid;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.cheapy.model.FoodOffer;
|
import org.springframework.cheapy.model.FoodOffer;
|
||||||
import org.springframework.cheapy.model.NuOffer;
|
import org.springframework.cheapy.model.NuOffer;
|
||||||
|
import org.springframework.cheapy.model.Owner;
|
||||||
import org.springframework.cheapy.model.SpeedOffer;
|
import org.springframework.cheapy.model.SpeedOffer;
|
||||||
import org.springframework.cheapy.model.StatusOffer;
|
import org.springframework.cheapy.model.StatusOffer;
|
||||||
import org.springframework.cheapy.model.TimeOffer;
|
import org.springframework.cheapy.model.TimeOffer;
|
||||||
|
@ -33,9 +34,12 @@ import org.springframework.cheapy.service.NuOfferService;
|
||||||
import org.springframework.cheapy.service.SpeedOfferService;
|
import org.springframework.cheapy.service.SpeedOfferService;
|
||||||
import org.springframework.cheapy.service.TimeOfferService;
|
import org.springframework.cheapy.service.TimeOfferService;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@ -51,21 +55,19 @@ public class NuOfferController {
|
||||||
|
|
||||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "nuOffers/createOrUpdateNuOfferForm";
|
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "nuOffers/createOrUpdateNuOfferForm";
|
||||||
|
|
||||||
private final FoodOfferService foodOfferService;
|
|
||||||
private final NuOfferService nuOfferService;
|
private final NuOfferService nuOfferService;
|
||||||
private final SpeedOfferService speedOfferService;
|
|
||||||
private final TimeOfferService timeOfferService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public NuOfferController(final FoodOfferService foodOfferService, final NuOfferService nuOfferService,
|
public NuOfferController(final NuOfferService nuOfferService) {
|
||||||
final SpeedOfferService speedOfferService, final TimeOfferService timeOfferService) {
|
|
||||||
this.foodOfferService = foodOfferService;
|
|
||||||
this.nuOfferService = nuOfferService;
|
this.nuOfferService = nuOfferService;
|
||||||
this.speedOfferService = speedOfferService;
|
|
||||||
this.timeOfferService = timeOfferService;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InitBinder
|
||||||
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
|
dataBinder.setDisallowedFields("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/offers/nu/{nuOfferId}")
|
@GetMapping("/offers/nu/{nuOfferId}")
|
||||||
|
@ -139,11 +141,31 @@ public class NuOfferController {
|
||||||
|
|
||||||
this.nuOfferService.saveNuOffer(nuOfferOld);
|
this.nuOfferService.saveNuOffer(nuOfferOld);
|
||||||
|
|
||||||
return "redirect:";
|
return "offers/offersList";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value ="/offers/nu/{nuOfferId}/edit")
|
||||||
|
public String initUpdateNuOfferForm(@PathVariable("nuOfferId") int nuOfferId, Model model) {
|
||||||
|
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||||
|
model.addAttribute(nuOffer);
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/offers/nu/{nuOfferId}/edit")
|
||||||
|
public String processUpdateOwnerForm(@Valid NuOffer nuOffer, BindingResult result,
|
||||||
|
@PathVariable("nuOfferId") int nuOfferId) {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nuOffer.setId(nuOfferId);
|
||||||
|
this.nuOfferService.saveNuOffer(nuOffer);
|
||||||
|
return "redirect:/offers/nu/{nuOfferId}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
|
||||||
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${foodOffer['new']}">New </c:if> FoodOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<petclinic:inputField label="Start Date" name="start"/>
|
||||||
|
<petclinic:inputField label="End Date" name="end"/>
|
||||||
|
<petclinic:inputField label="Food" name="food"/>
|
||||||
|
<petclinic:inputField label="Discount" name="discount"/>
|
||||||
|
<petclinic:inputField label="Units" name="units"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${foodOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Add Food Offer</button>
|
||||||
|
</c:when>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
24
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal file
24
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true"%>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
|
||||||
|
|
||||||
|
<form:form modelAttribute="foodOffer" class="form-horizontal">
|
||||||
|
<input type="hidden" name="food" value="${food_offer.food}" />
|
||||||
|
<input type="hidden" name="discount" value="${food_offer.discount}" />
|
||||||
|
<input type="hidden" name="units" value="${food_offer.units}" />
|
||||||
|
|
||||||
|
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||||
|
</form:form>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
|
@ -25,14 +25,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<c:choose>
|
|
||||||
<c:when test="${nuOffer['new']}">
|
|
||||||
<button class="btn btn-default" type="submit">Add Offer</button>
|
|
||||||
</c:when>
|
|
||||||
<c:otherwise>
|
|
||||||
<button class="btn btn-default" type="submit">Update Offer</button>
|
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||||
</c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form:form>
|
</form:form>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<cheapy:layout pageName="timeOffer">
|
<cheapy:layout pageName="timeOffer">
|
||||||
|
|
||||||
<h2>Oferta por número de comensales</h2>
|
<h2>Oferta por n<EFBFBD>mero de comensales</h2>
|
||||||
|
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -48,9 +48,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%>
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar Oferta</a>
|
||||||
|
|
||||||
|
<spring:url value="{nuOfferId}/disable" var="editUrl">
|
||||||
|
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Eliminar Oferta</a>
|
||||||
|
|
||||||
</cheapy:layout>
|
</cheapy:layout>
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true" %>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="TimeOffers">
|
||||||
|
<h2>
|
||||||
|
<c:if test="${timeOffer['new']}">New </c:if> TimeOffer
|
||||||
|
</h2>
|
||||||
|
<form:form modelAttribute="timeOffer" class="form-horizontal" id="add-timeOffer-form">
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<petclinic:inputField label="Fecha de inicio" name="start"/>
|
||||||
|
<petclinic:inputField label="Fecha de fin" name="end"/>
|
||||||
|
|
||||||
|
<petclinic:inputField label="Hora de inicio" name="init"/>
|
||||||
|
<petclinic:inputField label="Hora de final" name="finish"/>
|
||||||
|
<petclinic:inputField label="Decuento" name="discount"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${timeOffer['new']}">
|
||||||
|
<button class="btn btn-default" type="submit">Add Offer</button>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form:form>
|
||||||
|
</petclinic:layout>
|
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal file
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<%@ page session="false" trimDirectiveWhitespaces="true"%>
|
||||||
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||||
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
|
|
||||||
|
<petclinic:layout pageName="foodOffer">
|
||||||
|
|
||||||
|
<jsp:body>
|
||||||
|
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
|
||||||
|
|
||||||
|
<form:form modelAttribute="foodOffer" class="form-horizontal">
|
||||||
|
<input type="hidden" name="init" value="${time_offer.init}" />
|
||||||
|
<input type="hidden" name="finish" value="${time_offer.finish}" />
|
||||||
|
<input type="hidden" name="discount" value="${time_offer.discount}" />
|
||||||
|
|
||||||
|
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
|
||||||
|
</form:form>
|
||||||
|
|
||||||
|
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
|
||||||
|
|
||||||
|
</jsp:body>
|
||||||
|
</petclinic:layout>
|
Loading…
Reference in a new issue