adds possibility to specify multiple additional CSS files

Fri, 18 Dec 2020 15:54:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 18 Dec 2020 15:54:39 +0100
changeset 163
a5b9632729b6
parent 162
2adc8623dd89
child 164
003b08bb3f25

adds possibility to specify multiple additional CSS files

src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/site.jsp file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sat Dec 05 13:05:00 2020 +0100
+++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Fri Dec 18 15:54:39 2020 +0100
@@ -44,6 +44,7 @@
 import java.sql.SQLException;
 import java.util.*;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * A special implementation of a HTTPServlet which is focused on implementing
@@ -265,19 +266,19 @@
     }
 
     /**
-     * Specifies the name of an additional stylesheet used by the module.
-     * <p>
-     * Setting an additional stylesheet is optional, but quite common for HTML
-     * output.
+     * Specifies the names of additional stylesheets used by this Servlet.
      * <p>
      * It is sufficient to specify the name without any extension. The extension
      * is added automatically if not specified.
      *
-     * @param req        the servlet request object
-     * @param stylesheet the name of the stylesheet
+     * @param req         the servlet request object
+     * @param stylesheets the names of the stylesheets
      */
-    public void setStylesheet(HttpServletRequest req, String stylesheet) {
-        req.setAttribute(Constants.REQ_ATTR_STYLESHEET, enforceExt(stylesheet, ".css"));
+    public void setStylesheet(HttpServletRequest req, String ... stylesheets) {
+        req.setAttribute(Constants.REQ_ATTR_STYLESHEET, Arrays
+                .stream(stylesheets)
+                .map(s -> enforceExt(s, ".css"))
+                .collect(Collectors.toUnmodifiableList()));
     }
 
     /**
--- a/src/main/webapp/WEB-INF/jsp/site.jsp	Sat Dec 05 13:05:00 2020 +0100
+++ b/src/main/webapp/WEB-INF/jsp/site.jsp	Fri Dec 18 15:54:39 2020 +0100
@@ -71,7 +71,9 @@
     </c:if>
     <link rel="stylesheet" href="lightpit.css" type="text/css">
     <c:if test="${not empty extraCss}">
-        <link rel="stylesheet" href="${extraCss}" type="text/css">
+        <c:forEach items="${extraCss}" var="cssFile">
+        <link rel="stylesheet" href="${cssFile}" type="text/css">
+        </c:forEach>
     </c:if>
 </head>
 <body>

mercurial