Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes and subpackages in controllers

I'm using Play 2.1 and I'm having some odd problems.

I have a subpackage messages in the controllers package with a class i18n.java.

My routes file looks like this:

GET     \    controllers.messages.i18n.index()
POST    \    controllers.messages.i18n.process()

I now have a form with the following action:

@helper.form(action = routes.messages.i18n.process())

but this gives me an error:

value messages is not a member of object controllers.routes

I've used subpackages before in Play 2.0.4 and it worked fine like that, can anyone spot any errors in my configuration?

The routes file doesn't complain that it can't find the controller.

like image 442
Aerus Avatar asked Jun 09 '13 14:06

Aerus


People also ask

What is the use of mapareacontrollerroute's second parameter?

The second parameter, "Blog", is the area name. When matching a URL path like /Manage/Users/AddUser, the "blog_route" route generates the route values { area = Blog, controller = Users, action = AddUser }. The area route value is produced by a default value for area. The route created by MapAreaControllerRoute is equivalent to the following:

How to create a single route using mapcontrollerroute?

Inside the call to UseEndpoints, MapControllerRoute is used to create a single route. The single route is named default route. Most apps with controllers and views use a route template similar to the default route. REST APIs should use attribute routing.

What is the use of mapcontrollerroute inside useendpoints?

Inside the call to UseEndpoints, MapControllerRoute is used to create a single route. The single route is named default route. Most apps with controllers and views use a route template similar to the default route.

How to implement a route and a controller in JS?

For exemple: /controllers/products.js Starting from my previous article here an exemple of a route and a controller file. As you can see the implementation is very easy and straightforward. Then import all the controller functions. Lastly, use the router object to create a route and controller association.


2 Answers

The route should be controllers.messages.routes.i18n.process(). You can inspect the target/scala-2.10/src_managed directory to discover generated files.

And for information, Java coding conventions say that a class must start with an uppercase.

like image 105
Julien Lafont Avatar answered Oct 12 '22 13:10

Julien Lafont


FYI, in 2.2 it's slightly different.

routes.conf looks like:

GET  /admin/stuff  controllers.admin.StuffController.show()

in code looks like:

controllers.admin.routes.StuffController.show()
like image 11
duxx0r Avatar answered Oct 12 '22 13:10

duxx0r