Closed djx314 closed 9 years ago
I wonder if for 2.4 we can actually use DI instead of reflection? Seems like the Reverse Router should be able to be injected. /cc @jroper
Reverse routers can be injected, but no bindings are provided for them by default. Regardless, you would still have to use reflection - the reverse router classes simply do not exist at the time that this library is compiled, and therefore, there's nothing that they can be compiled against.
In Play 3, we're getting rid of global state, and that means we're going to have to rethink how assets are served, we're probably going to have to have some assets components, with a route that gets injected, and an injectable reverse router specifically for assets that is not generated but rather provided by Play. That will solve this issue.
Anyway, the suggested fix is what should be done to address this.
Thanks @jroper. I need to figure out how to fix my tests so that I can actually test this.
Is that a problem?
In your routes file, you have:
GET /webjars/:file controllers.WebJarAssets.at(file)
:file
only matches a single path segment, so when you put a value that contains slashes in there, they get escaped. If you want to match multiple path segments, you have to use *file
.
Oh man. Right. I'm on vacation so I have a good excuse for this. PR updated.
I've released 2.4.0-RC2
with this fix.
In play 2.4.0-RC1, reverse routers takes constructor params, so RequireJS.setup("javascripts/lib/archerui/") in template throws an exception like:
I suggest that just get the reverse route like this:
and it works well in my project.