Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass a list of data to backend?

 
sebastian edwin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


To passing a list of data (array, arraylist etc) from backend to frontend is simple. But another way round, How to pass a list of data from frontend to backend?

I tried

Frontend
==================
var arr = [
{name: 'firstname', value: 'Hello'},
{name: 'lastname', value: 'World'}
]

var assignToIdSelectedArr = new Array();
assignToIdSelectedArr.push("11");
assignToIdSelectedArr.push("22");

var obj = {
status : "weldMachineModel"
};
var obj2 = [1,2,3];

$.ajax({
type : 'POST',
url : "<s:url action="manageMaterial_test"/>",
dataType : 'json',
cache: false,
data: {
test : "test"
, mapExt : arr
},
success : function(data) {
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#waiting').hide(500);
alert("Server connection error.");
}
});

In backend,
==================
private String test;
private String[] testArr;
private List<String> testList = new ArrayList<String>();
private List<Material> materials = new ArrayList<Material>();
private List<Material> materialNOTs;

private Map map = new HashMap();
private Map<String, String> mapExt = new HashMap<String, String>();


But none of them can map to backend list / map, anyone can suggest me how to do that instead of using separator for long string?
sorry for bad english..

regards,
Jason
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic