aspose file tools*
The moose likes Struts and the fly likes How to pass a list of data to backend? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to pass a list of data to backend?" Watch "How to pass a list of data to backend?" New topic
Author

How to pass a list of data to backend?

sebastian edwin
Greenhorn

Joined: Nov 04, 2011
Posts: 1


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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass a list of data to backend?