I have a view form that contains a table with textfield inside it. I need to save the information of the table inside a database.
* javascript function *
function sendTableToServer()
{
var table;
table = document.getElementById('myTable');
var rowLength = table.rows.length;
var tableArray = [rowLength -1];
var JSONObject;
for (var tblRow = 1; tblRow < rowLength; tblRow++){
console.log("***** ROW CHANGE *****");
JSONObject = {
"rowIndex": "myTableRow" + tblRow,
"partNo": table.rows[tblRow].cells[0].firstChild.value,
"partName":table.rows[tblRow].cells[1].firstChild.value,
};
f24Array[tblRow] = JSONObject;
}
console.log(f24Array[rowLength-1]["rowIndex"]);
console.log(f24Array.length -1);
$.getJSON("f24BatcCreateEAF.do", {
type: "F24",
pRefForm: "DVL",
pF24Values: tableArray
}
, function(ans) {
console.log("The row is" +ans.strVar);
}
);
};
* controller *
public @ResponseBody
AjaxReturnMessage createEaf( Model model, HttpServletRequest pRequest, @RequestParam String type, @RequestBody String[] pF24Values ) throws Exception {
long eafId=0;
AjaxReturnMessage pARM = new AjaxReturnMessage();
log.info( "entering creatEaf );
try {
System.out.println("calling gF24BatchService");
eafId = gF24BatchService.createEAFRow( model, pp, type, pRefForm, pDescription );
pARM.setId( eafId );
pARM.setStrVar( "f24TableRow1" );
pARM.setCode( AjaxReturnMessage.STATUS_ERROR );
} catch ( Exception e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// return the jsp page only
return pARM;
}
When i trigger the sendTableToServer function i get an error "404". But if i remove the pF24Values from the JSON call and he service then there is no error.
How would it be possible for me to "catch" pF24Values without having to create a new object type. is this possible?
Thanks