0

I have a route defined as @com.xyx.abc(str: String) in my routes file.

I want to use this route in a template. I tried using

<a href="@com.xyx.abc("temp")/>

Obviously didn't work.

Thanks in advance.

Shashi
  • 91
  • 7

1 Answers1

1

Reverse routers are generated per package. So, if you have a package called com, a controller called xyx and a method called abc, then you can do this:

@com.routes.xyx.abc("temp")

Or if it's a more realistic @com.example.MyController.abc(str: String), then it would be:

@com.example.routes.MyController.abc("temp")
James Roper
  • 12,695
  • 46
  • 45
  • I have a package com.example, Controller - HelloController, method - getWorld(str:String). I am using subcut for DI in this controller. Please note, that I do no have a companion object. When I try to add the route in my href as @com.example.HelloController.getWorld("temp"). I get an error HelloController is not a member of package com.example, HelloContoller exists but it has no companion object. Do I have to create the companion object? This controller works just fine when I access it per the path defined in routes file. I run into the issue when I access this controller in the template. – Shashi Oct 08 '14 at 04:49
  • Note that you're missing **routes** in @com.example.HelloController.getWorld("temp"). In other words it should go like this: @com.example.routes.HelloController.getWorld("temp") – Daniel Olszewski Oct 08 '14 at 10:00
  • Clearly I need more sleep or more coffee. Thanks for pointing out Daniel. And of course thanks James. – Shashi Oct 08 '14 at 16:02