Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Add @template annotation to facilitate route definition #36

Open
mysticfall opened this issue Apr 8, 2015 · 1 comment
Open

Add @template annotation to facilitate route definition #36

mysticfall opened this issue Apr 8, 2015 · 1 comment

Comments

@mysticfall
Copy link
Member

Previously, there was PageController which can be used in conjunction with RouteProvider to easily declare template URL to be used for each controller instance.

However, as we replaced that trait with the recent constructor based DI implementation, we need another method to provide the functionality now.

We could use something like @template("/templates/edit.html") and probably, @title("Page Title") as well to facilitate defining routes.

@math85360
Copy link
Contributor

I think you could use an object companion for this. (I use this in my project)

class RoutingConfig(routeProvider: RouteProvider) extends Config {
  override def initialize() {
    super.initialize()
    routeProvider
        .when("/", MySampleController.route)
  }
}

object MySampleController {
    val route = Route("partials/controller/myTemplateUrl.htm", "Title", "mySampleController")
}

@injectable("mySampleController")
class MySampleController(scope: MyScope, http: HttpService) extends AbstractController[MyScope](scope) {
    ... your code ...
}

But I'm agree, an annotation solution will be more consise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants