I have a code block where i am dynamically adding
Below is the code that i am using -
<form:form role="form" method="post" id="addForm" action="/data/SomeAction" modelAttribute="someModel">
<div id="rowCabin1">
<div id="rowCabinData1">
<div class="row" id="cabinRow1">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<div class="form-group">
<form:input path="test" placeholder="Name" class="form-control" style="width:100%" />
</div>
</div>
</div>
</div>
</div>
</form:form>
Below is the javascript.
$().ready(function() {
var i=2;
$("#addRowCabin").click(function(){
$('#rowCabin1').append('<div id="rowCabinData'+i+'"><div class="row" id="cabinRow1"><div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"><div class="form-group"><form:input path="test" placeholder="Name" class="form-control" style="width:100%" /></div></div></div></div>');
i++;
});
$("#delRowCabin").click(function(){
if(i>2){
$("#rowCabinData"+(i-1)).remove();
i--;
}
});
});
Now when trying to load the page -
ERROR: org.springframework.web.servlet.tags.form.InputTag - Neither BindingResult nor plain target object for bean name 'test' available as request attribute
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'test' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
My gut feel was that it is because of the form:input not being part of the form:form tag itself. but since i am adding in the form tag, that should not be the case.
Please suggest.
AJ