Я пытаюсь отправить POST связанную форму, содержащую список. Это мой код шаблона scala:Play! 2 framework - не может получить список из формы
<input type="hidden" value="@recipe.name" name="recipes[0].recipe.name">
<input type="hidden" value="@recipe.id" name="recipes[1].recipe.id">
<input type="hidden" value="@recipe.url" name="recipes[2].recipe.url">
<input type="hidden" value="@user" name="user.email">
</fieldset>
<input type="submit" value="submit" class="btn btn-primary">} </td>
Размер списка - три, но все остальное равно null. Я могу получить электронную почту пользователя. Вот соответствующие области контроллера:
MenuPlan menuPlan = boundForm.get();
User user = User.getUser(menuPlan.user.email);
List<Recipe> recipesForm = menuPlan.recipes;
Logger.info("");
Logger.info("Number of recipes in menuPlan.recipes = " + menuPlan.recipes.size());
Logger.info("Name of recipe = " + menuPlan.recipes.get(1).name);
Logger.info("");
for(Recipe recipe : menuPlan.recipes){
Logger.info("");
Logger.info("The recipe id = " + recipe.id);
Logger.info("");
Logger.info("The recipe name = " + recipe.name);
Logger.info("");
Logger.info("The recipe url = " + recipe.url);
Logger.info("");
//Recipe recipeLoop = Recipe.findById(recipe.name);
//menuPlan.recipes.add(recipeLoop);
}
модель:
@ManyToMany
public List<Recipe> recipes;
@OneToOne(mappedBy="menuPlan")
public User user;
и @Id общественности Длинного идентификатора;
public String url;
@ManyToMany(cascade = CascadeType.ALL, mappedBy = "recipes")
public List<MenuPlan> menuPlans;
public String name;
Я попытался переключение mappedBy на каждую сторону ManyToMany, чтобы увидеть, если это делать с собственностью, но это не помогло.
Как уже упоминалось выше, любые предложения о том, почему элементы возвращают null, когда кажется, что их подбирают, будут очень благодарны. Любые предложения о том, что я могу проверить, также будут оценены!