An error has occurred - Please contact the system administrator

An error has occurred - Please contact the system administrator

sharadneo1sharadneo1 Posts: 16Questions: 1Answers: 0
edited May 2013 in General
Hi All,

i am using editor for crud operation. When i add , update and delete i use to get this "message An error has occurred - Please contact the system administrator" but not always and i tried to debug but not getting any error on console on chrome, and there is no issue in functionality its working fine. only the issue i am getting that error message on below of dialogue box.

Could you suggest me how to resolve.


Thanks in advance

sharad

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    This happens when there is a JSON error in the data returned by the server. What is being returned by the server?

    Allan
  • sharadneo1sharadneo1 Posts: 16Questions: 1Answers: 0
    json returned by the server is valid that i validate on http://jsonlint.com/, could you tell another solution.....
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Please link to the page you are working on. Without that I can't say what is going wrong.

    Allan
  • sharadneo1sharadneo1 Posts: 16Questions: 1Answers: 0
    // This is my js file

    function drawTable(){
    // axesGroupTable.fnClearTable();
    // axesGroupTable.fnAddData();
    axesGroupTable.fnDraw();

    }

    // use a global for the submit and return data rendering in the examples
    var axesGroupEditor;
    var axesGroupTable;


    $(document).ready(function() {
    // Create the form
    axesGroupEditor = new $.fn.dataTable.Editor( {
    "bProcesing" : true,
    "ajaxUrl" : "/ECE/axesGroup",
    "domTable" : "#axesGroup",
    "fields" : [ {
    "label" : "Axes Group:",
    "name" : "axesGroupTitleText",
    "type" : "text"
    }
    ]
    } );


    // New record
    $('#add').on('click', function (e) {
    e.preventDefault();
    axesGroupEditor.create(
    'Add New',[
    {
    "label": "Cancel" ,
    "fn": function ()
    {
    this.close();
    }
    },

    {
    "label": "Add",
    "fn": function ()
    {
    axesGroupEditor.submit(),
    this.close(),
    drawTable();

    } }
    ]

    );

    } );

    // Edit record
    $('#axesGroup').on('click', 'a.editor_edit', function (e) {
    e.preventDefault();
    axesGroupEditor.edit(
    $(this).parents('tr')[0],
    'Edit record',
    {
    "label": "Update",
    "fn": function ()
    {
    axesGroupEditor.submit(),
    this.close(),
    drawTable();

    } }
    );
    } );



    // Remove record
    $('#axesGroup').on('click', 'a.editor_remove', function (e) {
    e.preventDefault();
    axesGroupEditor.message( "Are you sure you want to delete this entry?" );
    axesGroupEditor.remove(
    $(this).parents('tr')[0],
    'Delete row',
    {
    "label": "Ok",
    "fn": function ()
    {
    axesGroupEditor.submit(),
    this.close(),
    drawTable();
    } }
    );
    } );


    // DataTables init
    axesGroupTable = $("#axesGroup").dataTable({
    "sPaginationType": "scrolling",
    "bProcesing" : true,
    "bServerSide" : true,
    "bLenthChange" : true,
    "iDisplayLength" : 10,
    "sScrollY" : "300px",
    "sAjaxSource" : '/ECE/getAxesGroups',
    "bSort" : false,
    "bFilter" : false,
    "aoColumns" : [
    {
    "sTitle" : "Axes Groups",
    "mData" : "axesGroupTitleText"
    },

    {
    "mData": null,
    "sClass": "right",
    "sDefaultContent": '  '
    }

    ],

    "fnServerData" : function(sSource, aoData, fnCallback) {
    $.ajax({
    "dataType" : 'json',
    "type" : "GET",
    "url" : sSource,
    "data" : aoData,
    "success" : function(data,textStatus,jqXHR)
    {
    fnCallback(data);
    }

    });
    },
    "sPaginationType" : "full_numbers"

    });

    } );


    //This is my controller

    package com.deere.eceweb.controller;

    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;

    import javax.annotation.Resource;
    import javax.servlet.http.HttpServletRequest;

    import org.codehaus.jackson.JsonProcessingException;
    import org.codehaus.jackson.map.ObjectMapper;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;

    import com.deere.ece.domain.AxesGroup;
    import com.deere.ece.form.AxesGroupMaintainForm;
    import com.deere.ece.service.ConfigurationService;
    import com.deere.ece.util.ApplicationUtil;

    @Controller(value = "maintainAxesGroupsController")
    public class MaintainAxesGroupsController {

    @Resource(name = "configurationService")
    private ConfigurationService configurationService;

    /** The Logger. */
    public final static Logger logger = LoggerFactory
    .getLogger(MaintainAxesGroupsController.class);

    @RequestMapping(value = { "/axesGroups" }, method = RequestMethod.GET)
    public String viewBaseLineText(Model model) {

    return "MaintainAxesGroup";
    }

    @RequestMapping(value = "/getAxesGroups", method = RequestMethod.GET )
    public @ResponseBody
    String getAxesGroups(@RequestParam int iDisplayStart,
    @RequestParam int iDisplayLength, @RequestParam int sEcho)
    throws IOException {

    DataTablesTO dt = new DataTablesTO();

    List axesGroupDmList = configurationService.getAllAxesGroups();
    List axesGroupDmListPage = configurationService.getAllAxesGroupsPage(iDisplayStart,iDisplayLength);


    List axesGroupFormList = new ArrayList();

    for (AxesGroup axesGroup : axesGroupDmListPage) {
    AxesGroupMaintainForm axesGroupForm = new AxesGroupMaintainForm();
    axesGroupForm.setAxesGroupId(axesGroup.getAxesGroupId());
    axesGroupForm.setAxesGroupTitleText(axesGroup.getAxesGroupTitleText());
    axesGroupForm.setAxesGroupGUIDText(axesGroup.getAxesGroupGUIDText());
    axesGroupForm.setDt_RowId(axesGroup.getAxesGroupId().toString());
    axesGroupFormList.add(axesGroupForm);

    }
    // this is the dataset reponse to client
    dt.setAaData(axesGroupFormList);
    // // the total data in db for datatables
    dt.setiTotalDisplayRecords(axesGroupDmList.size());
    // to calculate page no. and position the total data in db for datatables to calculate page no.
    dt.setiTotalRecords(axesGroupDmList.size());
    dt.setsEcho(sEcho);
    return toJson(dt);

    }

    private String toJson(DataTablesTO<?> dt) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    String jsonData = null;
    try {
    jsonData = mapper.writeValueAsString(dt);
    } catch (JsonProcessingException e) {
    e.printStackTrace();
    }
    logger.info(">>>>>" +jsonData);
    return jsonData;
    }


    @RequestMapping(value = "/axesGroup", params = "action=create", method = RequestMethod.POST )
    String createAxesGroup(
    @RequestParam(value = "data[axesGroupTitleText]", required = false) String axesGroup,
    HttpServletRequest request) {

    AxesGroupMaintainForm axesGroupForm = new AxesGroupMaintainForm();

    axesGroupForm.setAxesGroupTitleText(axesGroup);
    axesGroupForm.setAxesGroupGUIDText(ApplicationUtil.getConfigurationId());
    configurationService.addAxesGroup(axesGroupForm);

    return "MaintainAxesGroup";
    }

    @RequestMapping(value = "/axesGroup", params = "action=edit", method = RequestMethod.POST )
    String editAxesGroup(
    @RequestParam(value = "data[axesGroupTitleText]", required = false) String axesGroup,
    @RequestParam(value = "id", required = false) String editRowid,
    HttpServletRequest request) {

    AxesGroupMaintainForm axesGroupForm = new AxesGroupMaintainForm();

    axesGroupForm.setAxesGroupId(Integer.valueOf(editRowid));
    axesGroupForm.setAxesGroupTitleText(axesGroup);
    configurationService.updateAxesGroup(axesGroupForm);

    return "MaintainAxesGroup";
    }

    @RequestMapping(value = "/axesGroup", params = "action=remove", method = RequestMethod.POST )
    String removeAxesGroup(
    @RequestParam(value = "data[axesGroupTitleText]", required = false) String axesGroup,
    @RequestParam(value = "data[]", required = false) String deleteRowId,
    HttpServletRequest request) {

    configurationService.deleteAxesGroupById(Integer.valueOf(deleteRowId));

    return "MaintainAxesGroup";
    }


    }
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Sorry - but we need a link to be able to offer any help - please see: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • sharadneo1sharadneo1 Posts: 16Questions: 1Answers: 0
    Hey Allen - the issue is resolved that was happening because of we did not give @ responseBody in controller so it was not giving proper json as you said.

    Thanks alot - sharad :)
This discussion has been closed.