Reputation: 1048
I'm using URI routing in Play! for the first time. That's what I have:
Eclipse IDE, well updated IMHO;
Error:
Compilation error - not found: value id
In C:\play\play-2.2.1\samples\java\forms\app\views\contact\form.scala.html at line 7.
@import helper.twitterBootstrap._
@title = {
Add a new contact <small><a href="@routes.Contacts.edit(id: Long)">Or edit an existing contact</a></small>
}
@phoneField(field: Field, className: String = "phone") = {
@input(field, '_label -> "Phone numbers", '_class -> className) { (id, name, value, _) =>
...
Routes:
GET /contacts/:id controllers.Contacts.edit(id: Long)
Controller:
public static Result edit(Long id) {
Contact existingContact = Contact.find.byId(3L);
return ok(form.render(contactForm.fill(existingContact)));
}
Well, that's it! What else could I check? Thank you!
Upvotes: 0
Views: 1507
Reputation: 12850
When you refer to the routes.Contacts.edit
route, you need to pass an id. Right now, it looks like you just copied the parameter declaration (eg id: Long
) instead of choosing a meaningful id to pass.
Declare your title
block to accept the id
as a parameter, eg:
@title(id: Long) = {
Add a new contact <small><a href="@routes.Contacts.edit(id)">Or edit an existing contact</a></small>
}
Then when you use it, pass the id, eg:
@title(someId)
Upvotes: 2