I have 2 projects with the names:
- old
- new
I made a form in "old" with a radiobutton and some textfields to enter age, weight, ... Then I made a new project (activator new new) and developed the form further. The controller pre-fills the form, pre-selects the radiobutton etc. Now I wanted to update "old" and copied the code from "new" into "old". In ALL controller-classes, in ALL model-classes, in ALL views-classes is the EXACT same code! I even checked the file sizes manually several times, BUT in "old" the form does not get pre-filled! No matter what I do, nothing happens. I have no clue why this happens and what do to.
My code:
Application.java:
package controllers;
import models.User;
import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
public class Application extends Controller {
static Form<User> userForm = Form.form(User.class);
public static Result index() {
User user = new User();
Form<User> preFilledForm = userForm.fill(user);
return ok(views.html.index.render(preFilledForm));
}
}
User.java:
package models;
public class User {
public Integer gewicht;
public Integer groesse;
public Integer alter;
public Float grundUmsatz;
public String geschlecht = "Mann";
public User(){
gewicht = 0;
groesse = 0;
alter = 0;
geschlecht = "Mann";
}
}
index.scala.html:
@(userForm : Form[User])
@import helper._
@import helper.twitterBootstrap._
@main("App - index") {
@helper.form(action = routes.Application.submit(), 'id -> "userForm"){
<fieldset>
@helper.inputRadioGroup(
userForm("Geschlecht"),
options = options("Mann"->"Mann","Frau"->"Frau"),
'_label -> "Gender",
'_error -> userForm("Geschlecht").error.map(_.withMessage("select gender"))
)
</fieldset>
@helper.inputText(userForm("Gewicht"))
@helper.inputText(userForm("Groesse"))
@helper.inputText(userForm("Alter"))
<input type="submit" class="btn primary" value="Send">
}
}
main.scala.html:
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
routes-file:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
POST /auswertung/ controllers.Application.submit()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
Aucun commentaire:
Enregistrer un commentaire