vendredi 1 juillet 2016

net.sf.json.JSONException: There is a cycle in the hierarchy using Struts ModelDriven

I am using Struts class which implements ModelDriven. I am able to pass the data from Jquery and save the data on the database.

When I try to retrieve the data back and pass it back to JQuery, I am not sure why it's not available in JQuery. I am sure I am missing something with the basic flow..

Here is my action class.

public HttpHeaders index() {
    model = projectService.getProjectDetails(project.getUserID());
    return new DefaultHttpHeaders("success").setLocationId("");
} 

@Override
public Object getModel() {
    return project;
}

public Project getProject() {
    return project;
}

public void setProject(Project project) {
    this.project = project;
}

Here is my JQuery

function getProjectDetails() {
        var userID = localStorage.getItem('userID');
        var request = $.ajax({
            url : '/SUH/project.json',
            data : {
                userID : userID
            },
            dataType : 'json',
            type : 'GET',
            async : true
        });

        request.done(function(data) {
            console.log(JSON.stringify(data));
            $.each(data, function(index, element) {
                console.log('element project--->' + index + ":" + element);

            });
        });

        request.fail(function(jqXHR, textStatus) {
            console.log('faik');
        });

The model object in the Action class has all the data available but I tried to return model or project objects but both didn't work

Aucun commentaire:

Enregistrer un commentaire