How to show errors for multiple object forms - Play Framework 2 with Java -
i’m having trouble displaying errors of form containing multiple objects of class, in case productmilestone. i’m showing form milestones in table, displaying , updating works well. error template can’t displayed anymore error "[illegalstateexception: no value]". because erroneous form doesn’t contain values received form.get() method, in case it’s milestoneset. can make work errors displayed?
the problem for-loop in view:
view:
@(milestoneformset: form[productmilestone.milestoneset], productreleaseid: long) @*function called loop in form below*@ @milestonefields(milestone: productmilestone, index: integer) = { //…other fields @inputtext(milestoneformset("milestonelist[" + index + "].initialdate"), '_label -> "",'class -> "datepicker") …} @form(routes.productmilestones.submitedit(productreleaseid), 'id -> "submitmilestoneeditform") { @*here problem, when form has error can not access milestonelist using in loop*@ @for((milestone, index) <- milestoneformset.get.milestonelist.zipwithindex) { @milestonefields(milestone, index) } }
controller:
public static result submitedit(long productreleaseid) { form<milestoneset> filledform = form(milestoneset.class).bindfromrequest(); if (filledform.haserrors()) { return badrequest(views.html.milestonesedit.render(filledform, productreleaseid)); } else { milestoneset newmilestoneset = filledform.get(); //...update code }
the method trigger validation can't use in view, can pass set view variable.
Comments
Post a Comment