Object is Not a Member of Package. Note: class exists, but it has no companion object

sbt

(Kenny West) #1

Hi All,

I am getting this sbt clean compile error:

[error] /home/kenny/workspace/ace-4.0-golden/app/views/dash.scala.html:10:11: object header is not a member of package views.html.includes
[error] Note: class header exists, but it has no companion object.
[error] @includes.header("Dashboard", userId, partyId, appId)

Directory structure:

app
.... views
........ dash.scala.html
........ includes
............ header.scala.html

header.scala.html:

@import common.Configuration;
@import common.Global;
@import common.ZendeskJWT;
@import controllers.Admin;
@import models.User;
@import esavv.entities.App;
@import esavv.entities.Role;
@import esavv.entities.View;

@this(configuration: Configuration)

@(title: String, userId: String, partyId: Int, appId: Int)

<!DOCTYPE html>
<html class="no-js" lang="en" >
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv='cache-control' content='no-cache, no-store, must-revalidate'>
  <meta http-equiv='expires' content='0'>
  <meta http-equiv='pragma' content='no-cache'>
  <meta name="apple-mobile-web-app-capable" content="yes">

  <!-- Google Analytics (Used in Production Only)-->
  @if(configuration.getCurrentPlatform() == 1) {
     <script src="/assets/js/googleAnalytics.js"></script>
  }
  <!-- End Google Analytics -->

  <title>@title</title>
  <link rel="stylesheet" type="text/css" href="/assets/css/header.min.css">
  . . .

dash.scala.html:

@import esavv.entities.Person
@import esavv.entities.View
@import esavv.entities.Role
@import esavv.entities.App
@import esavv.entities.Widget
@import common.Configuration
@import common.Global

@(userId: String, partyId: Int, role: esavv.entities.Role, appId: Int, linkViewId: Int, widgetList: String)

@includes.header("Dashboard", userId, partyId, appId)

<script type="text/javascript">
$(document).ready(function() {
. . .

Google and Stack Overflow haven’t been able to help me. I was wondering if some Play experts had come across and solved this.


#2

What is includes supposed to be?


(Kenny West) #3

A directory under views. Thanks, I should have mentioned that.


#4

Header is another template then? Do you have template DI enabled perhaps?


(Ivano Pagano) #5

Is it not simply that the template engine is interpreting

@includes.header("Dashboard", userId, partyId, appId)

as a call to includes.header.apply(...)?


(Kenny West) #7

It’s enabled by default, but I tried explicitly enabling it and get the same error.


(Kenny West) #8

If so, what should I do? I was trying to follow the play-java-starter-example on GitHub.


(Ivano Pagano) #9

The starter example doesn’t have views organized in subdirectory, so I don’t get what you mean.

I’m not sure it’s related to the templates’ organization. I see that header has a constructor (@this(...)) so I guess you can’t include it anymore into other templates as a static function call (i.e. @includes.header(...,...))

I think you need to instantiate it with the constructor paramater and pass the instance to the dash template and only then call the instance with the ("Dashboard", userId, partyId, appId) arguments, just as if it was a function.

it wouldn’t make sense any other way, if you think about it:
when you do @includes.header("Dashboard", userId, partyId, appId) how could the instance of header included have been created, what will be his configuration?