Skip to content Skip to sidebar Skip to footer

How To Set Value In Arraylist Without Loading Whole Page..?

I am developing web application using struts2 hibernate. How to set a value in arraylist without loading the other. Front end is JSP Page. That page has multiple arraylist. Thank y

Solution 1:

Hi Jegatheesh,

Your requirement is very much similar to what I have implemented few days back in my project, where I have to pass an arraylist from JSP page to my struts Action class. So I used JSON for that.

Here is the working sample of my project:-

First make an object in javascript itself

var objectDetails = {};

Now add details to this object like :-

objectDetails.ID = $("#ID").val();objectDetails.Name = $("#Name").val();objectDetails.Address = $("#Address").val();objectDetails.Contact = $("#Contact").val();objectDetails.MailID = $("#MailID").val();

then make an array and Add this object to the array

var listArray = [];
listArray.push(objectDetails);

Now your JSON object is ready with all the data. All you have to do is just send it to your STRUTS Action class via JSON as follows :-

$.getJSON('AddList', {
    JSONObjectString: JSON.stringify(ObjectDetails)
});

Here in the above code AddList is your struts action which you have to map in your struts.xml and JSONObjectString is the property name which you have to make in your action class with getters and setters. Now just club all this code and paste into a jquery button click function.. so that you can execute it.

Post a Comment for "How To Set Value In Arraylist Without Loading Whole Page..?"