How do I bind a enum from my Model to a static parameter in my routes definition?
Example (made up):
Model:
class User (..)
{
public static enum TYPES { Default, Admin, Editor, Visitor }
}
Controller:
class Users (..)
{
public static void create(long parentUserId, User.TYPES type)
{
(..)
}
}
Routes:
GET /user/{parentUserId}/create/editor Users.create(type:User.TYPES.Editor)
View template:
<a href="@{Users.create(user.id, 'Editor')}">create editor</a>
or
<a href="@{Users.create(user.id, User.TYPES.Editor)}">create editor</a>
Both don't work. How should I set this up?
EDIT: I've tested this with working environment.
The following works:
Template:
<a href="@{Application.create(5, models.Game.GameType.Succession.name())}">create editor</a>
Route:
GET /user/{parentUserId}/create/{type}/editor Application.create
Controller:
public static void create(long parentUserId, Game.GameType type)
{ ... }
The route with a predefined parameter doesn't work:
GET /user/{parentUserId}/editor Application.create(type:models.Game.GameType.Succession.name())
It will always set type
to null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With