开发者

'getActionAnnotation' not found in a trait extending Controller

When using play-scala module, I write a Secure trait as the following:

trait Secure extends Controller {

  self:Controller =>

  @Before
  def checkAccess = {
    if (!session.contains("username")) {
      flash.put("url", if (request.method == "GET") request.url else "/")
      Action(Authentication.login)
    }
    var check = getActionAnnotation(classOf[Check])
    if (check != null) {
      check(check)
    }
    check = getControllerInheritedAnnotation(classOf[Check])
    if (check != null) {
      check(check)
    }
  }

  private def check(check: Check) {
    for (role <- check.value()) {
      if (!check(role)) {
        Forbidden
      }
    }
  }

}

But I get the f开发者_如何学JAVAollowing compilation error:

The file /app/controllers/Secure.scala could not be compiled. Error raised is : not found: value getActionAnnotation

How can I correct this?


getActionAnnotation() is defined in the Java Controller parent class, not in the Scala version (which is in ScalaController but gets "renamed" in the Scala module's source, see src/play/mvc/package.scala in the scala module).

I fear you either need to fork&patch the Scala module, or grab the source from the Java source (framework/src/play/mvc/Controller.java).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜