Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jlab.demo.presentation.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author ryans
*/
@WebServlet(
name = "hello",
urlPatterns = {"/hello"})
public class Hello extends HttpServlet {

/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/views/hello.jsp").forward(request, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,32 @@
<jsp:attribute name="stylesheets">
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/css/movie-table.css"/>
<!-- This is just demonstrating that style tags with an ID are copied in partial dialogs -->
<style id="movie-table-inline-style">
.multiselect-instructions {
font-style: italic;
}
</style>
</jsp:attribute>
<jsp:attribute name="scripts">
<script type="text/javascript"
src="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/js/movie-table.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/js/movie-table-multi.js"></script>
<!-- This is just demonstrating that script tags with an ID are copied in partial dialogs -->
<script id="movie-table-inline-script">
$(document).on("click", ".multiselect-instructions", function() {
console.log("clicked on instructions");
});
</script>
<script id="ignore-me-because-of-class" class="full-page-only">
// scripts with class full-page-only are ignored in partial page loads
$(document).on("click", ".multiselect-instructions", function() {
console.log("full page only - clicked on instructions");
});
</script>
<script>
// inline script tags are ignored by partial page loads
// inline script tags without an ID are ignored by partial page loads
$(function () {
movieTable.pageInit();
movieTableMulti.pageInit();
Expand Down
19 changes: 19 additions & 0 deletions smoothness-demo/src/main/webapp/WEB-INF/views/hello.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%@page contentType="text/html" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="s" uri="http://jlab.org/jsp/smoothness" %>
<c:set var="title" value="Hello"/>
<s:loose-page title="${title}" category="" description="Example loose page">
<jsp:attribute name="stylesheets">
</jsp:attribute>
<jsp:attribute name="scripts">
</jsp:attribute>
<jsp:body>
<section>
<c:if test="${param.partial ne 'Y'}">
<h2><c:out value="${title}"/></h2>
</c:if>
Hello World
</section>
</jsp:body>
</s:loose-page>
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,6 @@ th.scrollbar-header {
display: none;
}
/*Dialogs*/
.ui-dialog .page-dialog.ui-dialog-content {
margin: 0;
padding: 0;
}
.page-dialog .hide-in-dialog,
.dialog {
display: none;
Expand All @@ -659,7 +655,7 @@ th.scrollbar-header {
display: none;
}
.ui-dialog .ui-dialog-content {
padding: 16px;
padding: 0;
margin: 8px;
border: 1px outset black;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,42 @@ jlab.openPageInDialog = function (href) {
let title = $data.find("#partial").attr("data-title");

$('link[rel="stylesheet"]', css).each(function () {
if($(this).hasClass('full-page-only')) {
return true; // continue
}

let href = $(this).attr("href");

if($('link[rel="stylesheet"][href="' + href + '"]').length === 0) {
$(document).find("head").append(this);
}
});

$('style[id]', css).each(function () {
if($(this).hasClass('full-page-only')) {
return true; // continue
}

let id = $(this).attr("id");

if($('style[id="' + id + '"]').length === 0) {
$(document).find("head").append(this);
}
});

let waitingForLoadCount = 0;
let scripts = [];

$('script', js).each(function () {
let src = $(this).attr("src");
if($(this).hasClass('full-page-only')) {
return true; // continue
}

let src = $(this).attr("src"),
id = $(this).attr("id"),
text = $(this).text();

// We ignore script elements missing src attribute
// Script elements with src attribute not already in DOM
if(src && $('script[src="' + src + '"]').length === 0) {
waitingForLoadCount++;

Expand All @@ -269,6 +291,14 @@ jlab.openPageInDialog = function (href) {
}
};
script.src = src;
} else if(id && $('script[id="' + id + '"]').length === 0) {
// Inline scripts with an ID not already in DOM
// There is no onload event with inline scripts though.

const script = document.createElement('script');
script.id = id;
script.text = text;
document.body.appendChild(script);
}
});

Expand All @@ -277,9 +307,8 @@ jlab.openPageInDialog = function (href) {
} else {
// Start load
for (let i = 0; i < scripts.length; i++) {
let script = scripts[i];
let script = scripts[i]; // scripts with src only
document.body.appendChild(script);
//$(document).find("body").append(this); // jQuery will block load
}
}
}).catch(error => {
Expand Down
12 changes: 12 additions & 0 deletions smoothness-weblib/src/main/resources/META-INF/smoothness.tld
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
<name>help-panel</name>
<path>/META-INF/tags/help-panel.tag</path>
</tag-file>
<tag-file>
<name>loose-page</name>
<path>/META-INF/tags/loose-page.tag</path>
</tag-file>
<tag-file>
<name>smooth-script</name>
<path>/META-INF/tags/smooth-script.tag</path>
</tag-file>
<tag-file>
<name>smooth-style</name>
<path>/META-INF/tags/smooth-style.tag</path>
</tag-file>
<tag-file>
<name>tabbed-page</name>
<path>/META-INF/tags/tabbed-page.tag</path>
Expand Down
53 changes: 53 additions & 0 deletions smoothness-weblib/src/main/resources/META-INF/tags/loose-page.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<%@tag description="A Loose Page (no navigation) Template that supports partial pages and optionally smoothness resources" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="s" uri="http://jlab.org/jsp/smoothness"%>
<%@attribute name="stylesheets" fragment="true"%>
<%@attribute name="scripts" fragment="true"%>
<%@attribute name="title"%>
<%@attribute name="description"%>
<%@attribute name="category"%>
<%@attribute name="excludeSmoothResources" required="false" type="java.lang.Boolean" description="Defaults to false" %>
<c:set var="excludeSmoothResources" value="${(empty excludeSmoothResources) ? false : true}" />
<c:choose>
<c:when test="${param.partial eq 'Y'}">
<div id="partial" data-title="${title}">
<div id="partial-css">
<jsp:invoke fragment="stylesheets"/>
</div>
<div id="partial-html">
<div class="partial">
<jsp:doBody/>
</div>
</div>
<div id="partial-js">
<jsp:invoke fragment="scripts"/>
</div>
</div>
</c:when>
<c:otherwise>
<c:url var="domainRelativeReturnUrl" scope="request" context="/" value="${requestScope['javax.servlet.forward.request_uri']}${requestScope['javax.servlet.forward.query_string'] ne null ? '?'.concat(requestScope['javax.servlet.forward.query_string']) : ''}"/>
<c:set var="currentPath" scope="request" value="${requestScope['javax.servlet.forward.servlet_path']}"/>
<c:set var="resourceLocation" value="${env[initParam.appSpecificEnvPrefix.concat('_RESOURCE_LOCATION')]}"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="${fn:escapeXml(description)}">
<title><c:out value="${initParam.appShortName}"/> - ${empty category ? '' : category.concat(' - ')}${title}</title>
<link rel="shortcut icon" href="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/img/favicon.ico"/>
<c:if test="${not excludeSmoothResources}">
<s:smooth-style/>
</c:if>
<jsp:invoke fragment="stylesheets"/>
</head>
<body class="${param.print eq 'Y' ? 'print ' : ''} ${param.fullscreen eq 'Y' ? 'fullscreen' : ''}">
<jsp:doBody/>
<c:if test="${not excludeSmoothResources}">
<s:smooth-script/>
</c:if>
<jsp:invoke fragment="scripts"/>
</body>
</html>
</c:otherwise>
</c:choose>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<%@tag description="Smoothness Style Links" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:choose>
<c:when test="${'NONE' eq resourceLocation}">
</c:when>
<c:when test="${'CDN' eq resourceLocation}">
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery/3.7.1.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-ui/1.14.1/jquery-ui.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/uri/uri-1.14.1.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-plugins/select2/4.0.13/select2.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-plugins/maskedinput/jquery.maskedinput-1.3.1.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-plugins/timepicker/jquery-ui-timepicker-1.5.0.min.js"></script>
<script src="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jlab-theme/smoothness/${env[initParam.appSpecificEnvPrefix.concat('_SMOOTHNESS_VERSION')]}/js/smoothness.min.js"></script>
</c:when>
<c:otherwise>
<script src="${pageContext.request.contextPath}/resources/js/jquery-3.7.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/jquery-ui-1.14.1/jquery-ui.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/js/uri-1.14.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/jquery-plugins/select2/4.0.13/select2.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/jquery-plugins/maskedinput/1.3.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/jquery-plugins/timepicker/1.5.0.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/js/smoothness.js"></script>
</c:otherwise>
</c:choose>
<c:url var="iframeLoginUrl" value="${env['KEYCLOAK_FRONTEND_SERVER_URL']}/auth/realms/${env['KEYCLOAK_REALM']}/protocol/openid-connect/auth">
<c:param name="client_id" value="account"/>
<c:param name="kc_idp_hint" value="${env['KEYCLOAK_HEADLESS_IDP']}"/>
<c:param name="response_type" value="code"/>
<c:param name="redirect_uri" value="${env['KEYCLOAK_FRONTEND_SERVER_URL']}/auth/realms/${env['KEYCLOAK_REALM']}/account/"/>
</c:url>
<c:url var="suLogoutUrl" value="${env['KEYCLOAK_FRONTEND_SERVER_URL']}/auth/realms/${env['KEYCLOAK_REALM']}/protocol/openid-connect/logout">
<c:param name="redirect_uri" value="${env['KEYCLOAK_FRONTEND_SERVER_URL']}/auth/realms/${env['KEYCLOAK_REALM']}/account/"/>
</c:url>
<script type="text/javascript">
var jlab = jlab || {};
jlab.contextPath = '${pageContext.request.contextPath}';
jlab.logbookServerUrl = '${env["LOGBOOK_SERVER_URL"]}';
jlab.keycloakServerUrl = '${env["KEYCLOAK_FRONTEND_SERVER_URL"]}';
jlab.iframeLoginUrl = '${empty env['KEYCLOAK_HEADLESS_IDP'] ? '' : iframeLoginUrl}';
jlab.suLogoutUrl = '${suLogoutUrl}';
jlab.runUrl = '${env["JLAB_RUN_URL"]}';
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%@tag description="Smoothness Style Links" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:choose>
<c:when test="${'NONE' eq resourceLocation}">
</c:when>
<c:when test="${'CDN' eq resourceLocation}">
<link rel="stylesheet" type="text/css" href="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-ui/1.14.1/theme/smoothness/jquery-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jlab-theme/smoothness/${env[initParam.appSpecificEnvPrefix.concat('_SMOOTHNESS_VERSION')]}/css/smoothness.min.css"/>
<link rel="stylesheet" type="text/css" href="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-plugins/select2/4.0.13/select2.min.css"/>
<link rel="stylesheet" type="text/css" href="//${env[initParam.appSpecificEnvPrefix.concat('_CDN_SERVER')]}/jquery-plugins/timepicker/jquery-ui-timepicker-1.5.0.css"/>
</c:when>
<c:otherwise>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/jquery-ui-1.14.1/jquery-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/v${initParam.releaseNumber}/css/smoothness.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/jquery-plugins/select2/4.0.13/select2.min.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/jquery-plugins/timepicker/1.5.0.min.css"/>
</c:otherwise>
</c:choose>
Loading