i am new in JSON and datatable can anybody tell how can i parse json data from struts2 action class to my jsp page and represent it as a table using datatable?
Related
I am a newbie in Grails. On click of a button, I'm calling jQuery AJAX function. This function calls an action in a controller and renders the VO object as JSON. Now, this JSON is of a VO and I need to display this data in GSP which is opened as a model window. I am able to access the action output in jQuery. But how to use the same in GSP? (VO has Huge data). Can I keep data in session etc? Please advice
I need to create a mvc application which contain on grid view, that contains the data of the xml file, so I need to read xml file data and display that data in grid using mvc
We cannot write code for that. But I can suggest you that use XMLSerialization and map all XML data to Property Class and pass object of that property class to view as a model.
And in your view you can simply use all properties of that model.
References:
How to serialize and deserialize XML
List Model Binding in MVC
I badly need your help. I need to bind xml to grid in mvc4 using jquery mobile. i got xml through web service in controller but no idea how to make the xml content to grid and whether i need to pass the xml content to model ? I searched in net but didnt get clear example.
If this is a ajax called request, you can return back the xml as response of request and use an API to parse XML via Javascript. With that, you deserialize the xml just one time. If you parse to object and return model, you will deserialize two times.
Consider use: http://api.jquery.com/jquery.parsexml/
I am learning Struts2 and have the following question on submitting a form with Jquery serialize. I have an action class where I have an object called Policy and the policy class has set of fields as shown below. With jquery ajax I want to set a json string in my Action class and would like to deserialize it to an object.
How much ever I try, I am not able to set the string I defined in my action class. Below is the code
Class CassPolicy{
String policyNumber;
String name;
//getsets for members
}
Action:
Class PolicyAction{
String cassPolicyString;
CassPolicy cassPolicy = new CassPolicy();
//getsets for members
String save(){
//In save method I want to convert the policyString to policy object
//policyString always returns null
}
}
JSP:
$.ajax({
url:PolicyAction.action,
type:'post',
data:$("#policyForm").serialize(),
async:true,
success:function(data){
}
});
<s:form id="policyForm">
<s:textfield name="cassPolicy.policyNumber" label="policyNumber"></s:textfield>
<s:textfield name="cassPolicy.name" label="name"></s:textfield>
</s:form>
I even tried in ajax something like data:{cassPolicyString:$("#policyForm).serialize()}
Can someone help me point to the right direction or what is the right way to achieve my task?
I figured it out finally.. The issue is form serialize does not give a json format. I used the code in below link to serialize my form as json object and added a interceptor ref element to my action in struts.xml which finally assigned my form values to cassPolicy object.
Convert form data to JavaScript object with jQuery
I was wondering if there is any way to save form values in an xml format and reload it later.
I want to pass in my model (containing all form values) and save the form content in an xml file.
Many thanks
Sandra
Found a way to do this by serializing my model to xml by using the DataContractSerializer and them save the MemoryStream