I am trying to link CSS file in my velocity file but for some reason is not working properly.
Any ideas?
CSS filename:custom.css
velocity file snip code:
<html class="#language("lang.dir")" dir="#language("lang.dir")" lang="$w3c_language_id">
<head>
<title>GreenZap</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="/greenTheme-theme/docroot/css/custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/arial.js"></script>
<script type="text/javascript" src="js/cuf_run.js"></script>
</head>
On the other hand I get the words "javascript" and "href" underlined with error line. Nut later on int he code "href" is not underlined anymore.
Any help will be appreciated!
Thanks in advance!
EDIT:
I am using liferay 6.1 with Tomcat 7 and Liferay SDK for Eclipse. I am trying to integrate a website template to a liferay theme created with the SDK.
You need not have to link the css file to velocity.
Just follow these steps -
Im assuming that you have created theme and inside it you have copied the images,js,templates folder inside themes _diff folder .
Now inside your _diff/css/main.css
just copy these lines of code - #import url(custom.css);
HTH
Try without the docroot in the path:
<link href="/greenTheme-theme/css/custom.css" rel="stylesheet" type="text/css" />
you can use another way. Create file common.vm with content:
.error-message {
color: red;
}
In file container.vm, use:
#include("common.vm")
Related
I have a Spring boot web application, it works fine when running as executable jar, but when I build as war and deploy to Tomcat, the css, js files are not loading and looking into further, I found out all links are pointing to root context path "/", I tried changing base href = "./" this fixed the problem of loading css and js, but I need to do that in lot of pages.
Also the links in <a> still points to root context path and to make this work I need prefix'./' . Below are my code snips,
CSS and JS link
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/signin.css" rel="stylesheet">
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
Tag
<a class="topHeader" href="/activateAccount"></a>
Is there a shortcut to fix this problem or should I change <base href> and <a href> in all the pages? Any help is highly appreciated.
There is no short cut or quick fix for this, I removed "/" in links in all anchor tags and that worked for me.
Example
<a href="/resetPassword" style="float: right;">
changed to
<a href="resetPassword" style="float: right;">
I have been searching all day, moved the style.css everywhere and still not managed to get it loaded. The images wont load as well.
My structure:
But if i click the firefox button, it loads:
This is how the style.css is imported in the head of the index:
(tried all kind of combinations)
When i check the developer tools, it says 404 for GET request (style.css and the pictures)
Spring Boot knows where the static directory is, so you don't need to use the ../ technique to get to the files within. The other part is that you should be using an annotation to get there. It may depend on what view template you are using, but for thymeleaf this is how you would achieve pulling in the css file:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Your Title</title>
<link rel="stylesheet" th:href="#{/css/style.css}" />
</head>
Notice the annotation in th:href="#{/css/style.css}"
Make sure you include the namespace of your view template, th in the example.
Images work the same way:
<img th:src="#{/img/stanev2.png}" />
I'm working on a project in Spring MVC. I would like to connect CSS and js under it. However, for some reason, spring can not see these files. In the previous project which was configured using XML and everything worked fine. Any suggestion would be helpful.
Project Structure
<script type="text/javascript" src='<spring:url value="/resources/js/script.js"/>'></script>
<link href='<spring:url value="/resources/css/style.css"/>' rel="stylesheet" />
Configuration:
public void addResourceHandlers(final ResourceHandlerRegistry registry){
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
Move the resource folder under webapp folder. And with this line you can connect your css file.
<link rel="stylesheet" href="/css/styles.css">
Similarly write code to connect script like
<script type="text/javascript" src="/js/script.js"></script>
I am trying to experiment with Polymer in my scala project with Play framework. I followed the getting started at https://www.polymer-project.org/docs/start/creatingelements.html. In my index.scala.html I have included my-element.html and trying to access my-element. I am not seeing my contents in element as expected. Any suggestions about if what I am trying to do is feasible. Thank you in advance
On Mac, created a play-java app in IntelliJ.
Installed latest play framework 2.3.7 from https://www.playframework.com/download.
Extracted zip file and ran the activator command activator new to create new project
Opened Intellij IDEA and imported the new project
Ran project by activator run
Code attached below...
octo-element.html:
<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="octo-element" noscript>
<template>
<span>Hello from <b>octo-element</b>. This is my Shadow DOM.</span>
</template>
</polymer-element>
index.scala.html
#(message: String)
#main("Welcome to Play") {
#message
<octo-element></octo-element>
}
main.scala.html
#(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>#title</title>
<link rel="stylesheet" media="screen" href="#routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="#routes.Assets.at("images/favicon.png")">
<script src="#routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
<!-- 1. Load platform support before any code that touches the DOM. -->
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
<!-- 2. Load the component using an HTML Import -->
<link rel="import" href="../../bower_components/elements/octo-element.html">
</head>
<body>
#content
</body>
</html>
Application.java
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Your new application is ready."));
}
}
The polymer components (html and java scripts) should be created under assets. The assets route is defined in routes configuration.
The below code throws an error in Netbeans saying the include statement is not closed. I've tried a few things like #%> and I'm not able to figure out what's up. what am I doing wrong here?
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=request.getAttribute("title")%></title>
</head>
<body>
<%#include file=request.getAttribute("template")%>
</body>
</html>
Try using <jsp:directive.include/>:
<jsp:directive.include file="<%= request.getAttribute("template") %>"/>
Depending on the contents of your template, <jsp:include/> may also work:
<jsp:include path="<%= request.getAttribute("template") %>"/>
The include directive works at compile time (translation time), the path listed in file should be relative to the web application.
The include directive is processed when the JSP page is translated
into a servlet class. The effect of the directive is to insert the
text contained in another file--either static content or another JSP
page--in the including JSP page
if you want to use something more flexible when used to include files jstl tag < c:import >
Using the jstl we can also include those contents or files
which are not a part of the current web application but lying
somewhere outside the web application