In my play(FOR JAVA) app, I have a list of objects (java.util.List) that will be passed to a view and will be shown to the user. Then user can may or may not delete some of the objects in the list, and after that, I want to pass the edited list back to the Controller BUT I can't do the last part(passing from view to controller).
Because my list might be big, I don't want to do that with a GET (GET is also kind of unsafe?!) and don't know how to do it with a POST, (or is there any other solution?)
So it would be great if I could get some help with this.
The objects inside my list are from this type:
public class CalObj {
private String pdfFileName;
private String serialNo;
private Date calDate;
private Device device;
}
UPDATE: thanks @biesior , my View(calExtractionResults.scala.html) now looks like this:
@for(calObj <- calObjList) {
<tr>
<td> @calObj.getPdfFileName</td>
<td> @calObj.getSerialNo</td>
<td> @calObj.getDevice.name</td>
<td> @calObj.getDevice.calDateToString()</td>
<td> @calObj.getCalDate</td>
<td>
<form action="@DateExtractorContr.updateList(calObjList, calObj)" method="POST">
<input type="hidden" name="serialNo" value="@calObj.getSerialNo"/>
<input type="submit" value="Delete"/>
</form>
</td>
</tr>
}
and this is in my Controller:
public static Result updateList(List<CalObj> calObjs, CalObj objToDel){
List<CalObj> newList = calObjs;
newList.remove(objToDel);
return ok(calExtractionResults.render(newList));
}
but when I open the related page, there are problems:
- with the code above, I get:
[ConcurrentModificationException: null] - if I replace the updateList function with a dummy function that does not make concurrent exception, before showing the page, the program goes through that dummy function. before I even click on the Delete button.