I'm attempting to port an existing .NET MVC application to Java Play. This application makes use of ASP Master Pages, and I'm trying to duplicate this concept by using Play templates.
I've followed the documentation here: https://www.playframework.com/documentation/2.5.x/JavaTemplateUseCases
If I copy/paste the example, everything compiles. For some reason though, substituting my own parameters causes this error...
turkish:myApp adam$ ./bin/activator clean compile
[info] Loading project definition from /Users/adam/myApp/myApp/project
[info] Set current project to myApp (in build file:/Users/adam/myApp/myApp/)
[success] Total time: 0 s, completed Nov 30, 2016 10:11:09 AM
[info] Updating {file:/Users/adam/myApp/myApp/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 28 Scala sources and 9 Java sources to /Users/adam/myApp/myApp/target/scala-2.11/classes...
[error] /Users/adam/myApp/myApp/app/views/Shared/Documentation.scala.html:1: not found: value AdditionalPageIncludes
[error] @(AdditionalPageIncludes: Html)(SubNavigation: Html)(SectionTitle: Html)(TableOfContentsPlaceHolder: Html)(ArticlePlaceHolder: Html)
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 13 s, completed Nov 30, 2016 10:11:21 AM
As the example shows, I've declared (?) my parameters in the first line:
@(AdditionalPageIncludes: Html)(SubNavigation: Html)(SectionTitle: Html)(TableOfContentsPlaceHolder: Html)(ArticlePlaceHolder: Html)
I went through this exact process yesterday with a similar page and somehow eventually got everything to compile. It appeared to have been some combination of compiling the views first, then running a clean compile via activator. That doesn't seem to be working today.
It seems as though there are numerous artifacts left over after each project build, which is why I've been running clean compiles every time (which takes forever). I have a feeling I'm just not understanding something about how these templates/parameters are supposed to work.
Is this the correct way to define a template with parameters when using Java/Scala/Play? It seems as though it is expecting to use this parameter instead of declare it.
EDIT:
This is the template that compiles correctly (views/Shared/PublicMain.scala.html):
@(AdditionalPageIncludes: Html)(MainContent: Html)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/reset.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/public-main.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/ui.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/notification.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="/public/javascripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/public/javascripts/jquery-ui-1.8.16.custom.min.js"></script>
@AdditionalPageIncludes
<script type="text/javascript" src="/public/javascripts/Analytics.js"></script>
</head>
<body>
@MainContent
</body>
</html>
This is the template that fails to compile (views/Shared/DocumentationMain.scala.html):
@(AdditionalPageIncludes: Html)(SubNavigation: Html)(SectionTitle: Html)(TableOfContentsPlaceHolder: Html)(ArticlePlaceHolder: Html)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/reset.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/base.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/navigation.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/widget.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/profile.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/ui.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/notification.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/documentation.css" />
<link rel="Stylesheet" type="text/css" href="/public/stylesheets/jquery.ui.all.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic' rel='stylesheet' type='text/css' />
<!--AdditionalPageIncludes-->
</head>
<body>
<div id="Header">
<div id="HeaderContent">
<span style="float:right; line-height:30px; font-size:1.5em; vertical-align:middle; color:#eee; font-weight:bold;">Documentation</span>
<div style="height:30px;"></div>
<div style="clear:both;"></div>
</div>
</div>
<div id="SectionHeader">
<div id="SectionHeaderContent">
<div id="SectionNavigation">
<!--SubNavigation-->
</div>
<h2><!--SectionTitle--></h2>
</div>
</div>
<div id="Content">
<div class="WidgetCanvas RoundCorners">
<div style="clear:both;"></div>
</div>
</div>
</body>
</html>
I think I found the problem...since I'm migrating an existing application, I've been copying the original files into the new project folders and doing a few mass find/replace things. I tried creating a brand-new file within IntelliJ, added the template parameters I need, and everything compiles correctly.
So it appears you have to add new files straight from the IDE in order to make something behind the scenes link together. Otherwise it appears to be unable to find sources to compile. This still doesn't make any sense to me, but at least my templates are compiling now.