using multiple header, footer when using thymeleaf - java

when using thymeleaf, i created a seperate header and footer. but when i'm using it in another page it will generate error in IDE since xmlns:th="http://www.thymeleaf.org is not there. but the code is working in chrome. how can i eliminate error in IDE?
<!DOCTYPE html >
<html xmlns:th="http://thymeleaf.org">
<head th:fragment="head">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> Data Tables</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" th:href="#{/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/buttons.bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/font-awesome.min.css}">
<link rel="stylesheet" th:href="#{/css/dataTables.bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/fonts.css}">
<link rel="stylesheet" th:href="#{/css/AdminLTE.min.css}">
<link rel="stylesheet" th:href="#{/css/_all-skins.min.css}">
<link rel="stylesheet" th:href="#{/css/style.css}">
</head>
header.html
<div th:replace="fragments/head.html :: head "></div>
<div th:replace="fragments/header.html :: header"></div>
<div th:replace="fragments/sidenav.html :: sidenav"></div>
<div th:replace="fragments/footer.html :: footer"></div>
index.html
in index.html there is an error

Related

Unable to see the highlight code on browser side in source code in Spring boot(thymeleaf-extras-springsecurity5) application?

I'm working on embedded Okta login page in that I'm using 'thymeleaf'.This Thymleaf code not shown in browser side code and after Authentication below code not working. Please help on this code.
========= Code =========
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Login</title>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>
<link th:href="#{/css/touch-style.css}" rel="stylesheet" type="text/css"/>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css" />
<link href="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"/>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"/>
<link href="css/okta.css" rel="stylesheet" type="text/css"/>
<script src="https://global.oktacdn.com/okta-signin-widget/6.6.2/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/6.6.2/css/okta-sign-in.min.css" type="text/css" rel="stylesheet"/>
<link href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/2.13.0/css/okta-theme.css" type="text/css" rel="stylesheet"/>
</head>
<body class="login-page">
<div id="okta-login-container"></div>
<div sec:authorize="isAuthenticated()">
<script type="text/javascript">
window.location.href = "/dashboard";
</script>
</div>
<div>Normal Text Message</div>
<div th:replace="fragments/footer :: footer"></div>
<script th:src="#{/js/login.js}"></script>
</body>
</html>

Is there a way to include CSS in a FreeMarker Email Template?

I am creating an email using Spring Boot and Apache FreeMarker. Is it possible to include CSS in the email without needing to have a huge tag in the header?
Here is an example .ftl file that I would like to link a .css file to:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="style-in-css-doc">
Some text to be styled
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
You can simply include the css file into your template by putting css code in another ftl file and then include it to your main template with include directive
<#include path>

Get an XML response with a java http post request on GeoNetwork

I try to complete automatically my GeoNetwork catalog with java http post request. No matter the library (io, apache commons, geotools), I always have the same html response as follow.
<!DOCTYPE html
SYSTEM "html">
<html ng-app="gn_login" lang="eng" id="ng-app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My GeoNetwork catalogue - My organization</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../i$
<link href="rss.search?sortBy=changeDate" rel="alternate" type="applicati$
<link href="portal.opensearch" rel="search" type="application/opensearchd$
<link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" med$
<link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" $
<link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="scree$
<link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" med$
</head>
<body data-ng-controller="GnCatController">
<div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTo$
<div data-ng-include="'../../catalog/templates/signin.html'"></div>
<div ng-include="'../../catalog/templates/info.html'"></div><script src="$
<div class="alert" data-ng-hide=""><strong></strong>
</div>
</noscript>
</body>
</html>
I start my GeoNetwork with jetty server. Do you know how to directly request the server to get an XML response?
Probably you are trying to make the request to a protected URL. You must make a request to the login service first, keep the JSESSIONID cookie it returns and then send it to the original service you wanted to request.

Why bootstrap does not work in eclipse?

Why bootstrap does not work ? I download the folders from site and I add it in the root of the WebContent like WebContent/bootstrap/css..js..fonts
The jsp looks like this
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link href='http://fonts.googleapis.com/css?family=Roboto'
rel='stylesheet' type='text/css'>
<title>Comment Box</title>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"
type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="row" id="featuresheading">
<div class="col-lg-12">
<div class="table-responsive">
<table class="table ta................etc
but why the table does not appear as it suposed? please help
Try a full publish to get your bootstrap files into your application server.
I got bootstrap to work in a .jsp in Eclipse. Here's my configuration:
Here's the markup in the .jsp...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Bootstrap</title>
<link href="bootstrap-3.3.6/dist/css/bootstrap.css" rel="stylesheet"
type="text/css" />
</head>
<body>
<div class="container">
<h1>Test Bootstrap</h1>
<table class="table table-striped">
<tr>
<td>Bootstrap</td>
</tr>
<tr>
<td>is working</td>
</tr>
</table>
</div>
</body>
</html>`
`You don't need to reference bootstrap two times. Just pick the full or the minified version. Good luck.

Thymeleaf namespace in html files display errors in Netbeans - How can I get it pass HTML checking?

Netbeans HTML checking doesn't like my thymeleaf namespace.
Here is my HTML Thymleaf file:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<object th:include="fragments/meta :: meta" th:remove="tag" />
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'/>
<link href="/../../../webjars/Semantic-UI/2.0.6/semantic.min.css" rel="stylesheet" th:href="#{/webjars/Semantic-UI/2.0.6/semantic.min.css}"/>
<link href="../../../css/core.css" rel="stylesheet" th:href="#{/css/core.css}" />
<link href="../../../css/product.css" rel="stylesheet" th:href="#{/css/product.css}" />
</head>
<body>
</body>
</html>
This is the error displayed in Netbeans:
How can I get Netbeans to play nicely with Thymeleaf?
Try to fix it in this way you may ignore spring security thing.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="utf-8"/>
<title>Sample</title>
<link th:href="#{/resources/css/bootstrap.css}" rel="stylesheet" type="text/css"/>
<link th:href="#{/resources/css/bootstrap-theme.css}" rel="stylesheet" type="text/css"/>
</head>
I found out how to disable these errors when I was taking this spring security tutorial
Simply by adding this to html tag:
xmlns="http://www.w3.org/1999/xhtml"
what's even cooler, netbeans now tracks if you closed every tag with slash "/" in document.

Categories