From d69b89691cad7ada61dadd4810b87efea12954ec Mon Sep 17 00:00:00 2001 From: Antoine Rey <antoine.rey@gmail.com> Date: Fri, 7 Oct 2016 18:21:09 +0200 Subject: [PATCH] Fix #171 Jetty 9 support by removing Dandelion --- pom.xml | 26 ++----- readme.md | 13 ---- .../petclinic/config/DandelionConfig.java | 74 ------------------- .../datatables/datatables.properties | 6 -- src/main/webapp/WEB-INF/jetty-web.xml | 7 ++ .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 59 +++++++++------ src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 36 +++++---- 7 files changed, 74 insertions(+), 147 deletions(-) delete mode 100644 src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java delete mode 100644 src/main/resources/dandelion/datatables/datatables.properties create mode 100644 src/main/webapp/WEB-INF/jetty-web.xml diff --git a/pom.xml b/pom.xml index d5c7691..aa14247 100644 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,6 @@ <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version> <webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version> <webjars-jquery.version>2.2.4</webjars-jquery.version> - <dandelion.version>1.1.1</dandelion.version> - <dandelion.datatables.version>1.1.0</dandelion.datatables.version> <cobertura.version>2.7</cobertura.version> @@ -54,6 +52,13 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> + <!-- Uncomment bellow lines in order to deploy the Springboot Petlinic WAR file into an external Jetty --> + <!--exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + </exclusion> + </exclusions--> </dependency> <dependency> @@ -90,23 +95,6 @@ <artifactId>ehcache</artifactId> </dependency> - <!-- Dandelion --> - <dependency> - <groupId>com.github.dandelion</groupId> - <artifactId>dandelion-jsp</artifactId> - <version>${dandelion.version}</version> - </dependency> - <dependency> - <groupId>com.github.dandelion</groupId> - <artifactId>datatables-jsp</artifactId> - <version>${dandelion.datatables.version}</version> - </dependency> - <dependency> - <groupId>com.github.dandelion</groupId> - <artifactId>datatables-export-itext</artifactId> - <version>${dandelion.datatables.version}</version> - </dependency> - <!-- webjars --> <dependency> <groupId>org.webjars</groupId> diff --git a/readme.md b/readme.md index bcedd41..d0ad14f 100644 --- a/readme.md +++ b/readme.md @@ -73,10 +73,6 @@ File -> Import -> Maven -> Existing Maven project <td>Caching</td> <td>Use of EhCache <a href="/src/main/java/org/springframework/samples/petclinic/config/CacheConfig.java">CacheConfig.java</a> <a href="/src/main/resources/ehcache.xml">ehcache.xml</a></td> </tr> - <tr> - <td>Dandelion</td> - <td>DatatablesFilter, DandelionFilter and DandelionServlet registration <a href="/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java">DandelionConfig.java</a></td> - </tr> <tr> <td>Spring MVC - XML integration</td> <td><a href="/src/main/java/org/springframework/samples/petclinic/config/CustomViewsConfiguration.java">CustomViewsConfiguration.java</a></td> @@ -104,15 +100,6 @@ File -> Import -> Maven -> Existing Maven project <a href="/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp#L12">sample usage in JSP</a></td> </td> </tr> - <tr> - <td>Dandelion-datatables</td> - <td> - <a href="/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp">ownersList.jsp</a> - <a href="/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp">vetList.jsp</a> - <a href="/src/main/webapp/WEB-INF/web.xml">web.xml</a> - <a href="/src/main/resources/dandelion/datatables/datatables.properties">datatables.properties</a> - </td> - </tr> </table> diff --git a/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java b/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java deleted file mode 100644 index b13737f..0000000 --- a/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2002-2016 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 - * - * http://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.samples.petclinic.config; - -import com.github.dandelion.core.web.DandelionFilter; -import com.github.dandelion.core.web.DandelionServlet; -import com.github.dandelion.datatables.core.web.filter.DatatablesFilter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Description; -import org.springframework.core.env.Environment; - -import javax.annotation.PostConstruct; - -/** - * Java configuration for the Dandelion datatables component. - * - * @author Antoine Rey - */ -@Configuration -public class DandelionConfig { - - @Autowired - private Environment environment; - - @PostConstruct - public void init() { - if (environment.acceptsProfiles("production")) { - System.setProperty("dandelion.profile.active", "prod"); - } - } - - @Bean - @Description("Dandelion filter definition and mapping") - public FilterRegistrationBean filterRegistrationBean() { - FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); - filterRegistrationBean.setFilter(new DandelionFilter()); - return filterRegistrationBean; - } - - @Bean - @Description("Dandelion-Datatables filter, used for basic export") - public FilterRegistrationBean datatablesRegistrationBean() { - FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); - filterRegistrationBean.setFilter(new DatatablesFilter()); - return filterRegistrationBean; - } - - @Bean - public ServletRegistrationBean servletRegistrationBean() { - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); - servletRegistrationBean.setServlet(new DandelionServlet()); - servletRegistrationBean.addUrlMappings("/dandelion-assets/*"); - servletRegistrationBean.setName("dandelionServlet"); - return servletRegistrationBean; - } -} diff --git a/src/main/resources/dandelion/datatables/datatables.properties b/src/main/resources/dandelion/datatables/datatables.properties deleted file mode 100644 index 08b1e43..0000000 --- a/src/main/resources/dandelion/datatables/datatables.properties +++ /dev/null @@ -1,6 +0,0 @@ -# ================================== -# Dandelion-Datatables configuration -# ================================== - -# Disable the asset management of Dandelion-Core for all non-DataTable-related assets -main.standalone=true \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jetty-web.xml b/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 0000000..5bb92f0 --- /dev/null +++ b/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> +<Configure class="org.eclipse.jetty.webapp.WebAppContext"> + <!-- Fix Jetty 9 issue --> + <!-- http://stackoverflow.com/questions/32643530/classpath-issue-between-jetty-maven-plugin-and-tomcat-jdbc-8-0-9-leading-to-ser --> + <Set name="parentLoaderPriority">true</Set> +</Configure> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 2f86248..08b1605 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -3,31 +3,46 @@ <%@ 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="datatables" uri="http://github.com/dandelion/datatables" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> <petclinic:layout pageName="owners"> <h2>Owners</h2> - <datatables:table id="owners" data="${selections}" row="owner" - cssClass="table table-striped" pageable="false" info="false" export="pdf"> - <datatables:column title="Name" cssStyle="width: 150px;" display="html"> - <spring:url value="/owners/{ownerId}.html" var="ownerUrl"> - <spring:param name="ownerId" value="${owner.id}"/> - </spring:url> - <a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a> - </datatables:column> - <datatables:column title="Name" display="pdf"> - <c:out value="${owner.firstName} ${owner.lastName}"/> - </datatables:column> - <datatables:column title="Address" property="address" cssStyle="width: 200px;"/> - <datatables:column title="City" property="city"/> - <datatables:column title="Telephone" property="telephone"/> - <datatables:column title="Pets" cssStyle="width: 100px;"> - <c:forEach var="pet" items="${owner.pets}"> - <c:out value="${pet.name}"/> - </c:forEach> - </datatables:column> - <datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;"/> - </datatables:table> + <table id="vets" class="table table-striped"> + <thead> + <tr> + <th style="width: 150px;">Name</th> + <th style="width: 200px;">Address</th> + <th>City</th> + <th style="width: 120px">Telephone</th> + <th>Pets</th> + </tr> + </thead> + <tbody> + <c:forEach items="${selections}" var="owner"> + <tr> + <td> + <spring:url value="/owners/{ownerId}.html" var="ownerUrl"> + <spring:param name="ownerId" value="${owner.id}"/> + </spring:url> + <a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a> + </td> + <td> + <c:out value="${owner.address}"/> + </td> + <td> + <c:out value="${owner.city}"/> + </td> + <td> + <c:out value="${owner.telephone}"/> + </td> + <td> + <c:forEach var="pet" items="${owner.pets}"> + <c:out value="${pet.name} "/> + </c:forEach> + </td> + </tr> + </c:forEach> + </tbody> + </table> </petclinic:layout> diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index d8e48e8..a46434a 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -2,24 +2,34 @@ <%@ 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="datatables" uri="http://github.com/dandelion/datatables" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> <petclinic:layout pageName="vets"> <h2>Veterinarians</h2> - <datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped" - pageable="false" info="false"> - <datatables:column title="Name"> - <c:out value="${vet.firstName} ${vet.lastName}"/> - </datatables:column> - <datatables:column title="Specialties"> - <c:forEach var="specialty" items="${vet.specialties}"> - <c:out value="${specialty.name}"/> - </c:forEach> - <c:if test="${vet.nrOfSpecialties == 0}">none</c:if> - </datatables:column> - </datatables:table> + <table id="vets" class="table table-striped"> + <thead> + <tr> + <th>Name</th> + <th>Specialties</th> + </tr> + </thead> + <tbody> + <c:forEach items="${vets.vetList}" var="vet"> + <tr> + <td> + <c:out value="${vet.firstName} ${vet.lastName}"/> + </td> + <td> + <c:forEach var="specialty" items="${vet.specialties}"> + <c:out value="${specialty.name} "/> + </c:forEach> + <c:if test="${vet.nrOfSpecialties == 0}">none</c:if> + </td> + </tr> + </c:forEach> + </tbody> + </table> <table class="table-buttons"> <tr> -- GitLab