Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples needed for Play 2.8.x Template Constraints #113

Closed
c-lee8 opened this issue May 18, 2021 · 1 comment
Closed

Examples needed for Play 2.8.x Template Constraints #113

c-lee8 opened this issue May 18, 2021 · 1 comment

Comments

@c-lee8
Copy link

c-lee8 commented May 18, 2021

Hi Steve,

According to the Guide https://deadbolt-java.readme.io/docs/template-constraints

We should include these lines in the view template:

@import be.objectify.deadbolt.java.views.html.di.{subjectPresent, subjectPresentOr}

@subjectPresent() {
    This content will be present if handler#getSubject results in a Some 
}

@subjectPresentOr() {
    This content will be present if handler#getSubject results in a Some 
} {
  fallback content
}

However this resulted in

play.sbt.PlayExceptions$CompilationException: Compilation error[not found: value subjectPresent]
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:34)
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:34)
        at scala.Option.map(Option.scala:230)
        at play.sbt.run.PlayReload$.$anonfun$taskFailureHandler$8(PlayReload.scala:131)
        at scala.Option.map(Option.scala:230)
        at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:104)
        at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:38)
        at play.sbt.run.PlayReload$.$anonfun$compile$3(PlayReload.scala:156)
        at scala.util.Either$LeftProjection.map(Either.scala:573)
        at play.sbt.run.PlayReload$.compile(PlayReload.scala:156)

Am I missing some dependencies? I am able to set up the Controller constraints. Perhaps the issue is Dependency Injection related?

I am using
libraryDependencies += "be.objectify" %% "deadbolt-java" % "2.8.1"

on Play Framework 2.8.8

Thank you

@c-lee8
Copy link
Author

c-lee8 commented May 19, 2021

Ok I found the issue #45 which answered what I was looking for in the closed issues, thanks.

Essentially I needed to use Dependency Injection to put the constraints into the template

https://www.playframework.com/documentation/2.8.x/JavaTemplatesDependencyInjection

@c-lee8 c-lee8 closed this as completed May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant