So, what I did:
- Created a class Foo.java, which is an entity.
- Created a 'helper' class FooList.java, which has only one variable: List<Foo> foos. This class is not an entity.
- In my Controller I pass a Form<FooList> to my view.
- In my view I've created my 'own field':
@fooFields(form: Form[FooList], index: Integer) = {
<div class="foo">
@inputText(form("foos[" + index + "].name"), '_label -> "Foo's name")
@inputText(form("foos[" + index + "].age"), '_label -> "Foo's age")
</div>
}
- And in the main part of my view:
@form(routes.Foos.createFoos()) {
<div class="foos">
@fooFields(fooListForm, 0)
@fooFields(fooListForm, 1)
@fooFields(fooListForm, 2)
</div>
<input type="submit" value="Submit">
}
Form<SubtaskList> form = form(SubtaskList.class).fill(list);.
play - Cannot invoke the action, eventually got an error: org.springframework.beans.InvalidPropertyException: Invalid property 'subtaskList[0]' of bean class [models.qosdatamodel.SubtaskList]: Illegal attempt to get property 'subtaskList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'subtaskList' of bean class [models.qosdatamodel.SubtaskList]: Could not instantiate property type [models.qosdatamodel.Subtask] to auto-grow nested property path: java.lang.InstantiationException
<!-- Parameter Name--> <td>@subtaskForm.get.subtaskList.get(index).getGivenParameter.name</td> <!-- Parameter Value--> <td>@subtaskForm.get.subtaskList.get(index).getGivenParameter.value</td> <!-- Parameter Type--> <td>@select(subtaskForm("models.qosdatamodel.SubtaskList.subtaskList["+index+"].typeChosen"), options= options(models.qosdatamodel.Subtask.paramTypeList), '_default -> "--- Choose the parameter type ---", '_label -> None )</td> <!-- Candidate Parameter Chosen--> <td>@select(subtaskForm("subtaskList["+index+"].chosenParameter"), options = options(models.qosdatamodel.Subtask.candidateParams(subtaskForm.get.subtaskList.get(index).getAssociatedTask.getId)), '_default -> "--- Choose the candidate parameter ---", '_label -> None )</td> <!-- Chosen Upper Bound Formula--> <td>@select(subtaskForm("subtaskList["+index+"].chosenUpperBound"), options = options(models.qosdatamodel.Subtask.boundList), '_default -> "--- Choose the upper bound ---", '_label -> None )</td> <!-- Chosen Lower Bound Formula--> <td>@select(subtaskForm("subtaskList["+index+"].chosenLowerBound"), options = options(models.qosdatamodel.Subtask.boundList), '_default -> "--- Choose the lower bound ---", '_label -> None )</td>
[debug] application - put: <models.qosdatamodel.SubtaskList.subtaskList[0].typeChosen,cost of service execution>
[debug] application - put: <subtaskList[0].chosenParameter,Execution Time>
[debug] application - put: <subtaskList[0].chosenUpperBound,Sum>
[debug] application - put: <subtaskList[0].chosenLowerBound,Product>
[debug] application - put: <models.qosdatamodel.SubtaskList.subtaskList[1].typeChosen,throughput>
[debug] application - put: <subtaskList[1].chosenParameter,Total Output>
[debug] application - put: <subtaskList[1].chosenUpperBound,Product>
[debug] application - put: <subtaskList[1].chosenLowerBound,Min>
[debug] application - put: <models.qosdatamodel.SubtaskList.subtaskList[2].typeChosen,uptime probability>
[debug] application - put: <subtaskList[2].chosenParameter,Total Availability>
[debug] application - put: <subtaskList[2].chosenUpperBound,Sum>
[debug] application - put: <subtaskList[2].chosenLowerBound,Product>