0

I am completely new to Extjs and struts2 and was trying a new project of my own. However, while passing the json data from struts action class, I am continuosly getting this error: Ext.JSON.decode(): You're trying to decode an invalid JSON String I am using: JDK 1.8
Apache Tomcat 8.5.55
Extjs 6.0.2
IDE Eclipse
My struts.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
   "http://struts.apache.org/dtds/struts-2.5.dtd">

<struts>
    <package name="default" extends="json-default">
        <action 
            name = "generateCustomerJson" 
            class = "com.proj.Action.CustomerDataJsonCreator"
            method = "">
            <result name = "Success">/index.jsp
            </result>
        </action>
    </package>
</struts>

My action class is:

package com.proj.Action;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.proj.DAO.DBConnector;
import com.proj.SqlQueryGenerator;

public class CustomerDataJsonCreator {
    
    private Connection conn = null;
    private PreparedStatement preparedStatement = null;
    private ResultSet resultSet = null;
    private HashMap<String,Object> record= null;
    private ArrayList<Object> arrayList = new ArrayList<Object>();
    private String data = null;
    private JsonElement element = null;
    private JsonObject object = new JsonObject();


    //connection to DB
    public CustomerDataJsonCreator() {
        conn = DBConnector.conDB();
    }


    public String execute() {
            
            setPreparedStatement(SqlQueryGenerator.generator("Select"));
            preparedStatement = getPreparedStatement();
            
            setResultSet(preparedStatement);
            resultSet = getResultSet();
        
        try {
            
            while (resultSet.next()) {
                 record = new HashMap<>();
                 record.put("pk_id",resultSet.getInt(1));
                 record.put("acct_doc_header_id", resultSet.getInt(2));
                 record.put("company_id", resultSet.getInt(3));
                 record.put("document_number", resultSet.getInt(4));
                 record.put("document_number_norm", resultSet.getInt(5));
                 record.put("business_code", resultSet.getString(6));
                 record.put("create_year", resultSet.getString(7));
                 record.put("document_line_number", resultSet.getInt(8));
                 record.put("doctype", resultSet.getString(9));
                 record.put("customer_number", resultSet.getInt(10));
                 record.put("customer_number_norm", resultSet.getInt(11));
                 record.put("fk_customer_map_id", resultSet.getInt(12));
                 record.put("customer_name", resultSet.getString(13));
                 record.put("division", resultSet.getString(14));
                 record.put("document_create_date", resultSet.getDate(15));
                 record.put("document_create_date_norm", resultSet.getDate(16));
                 record.put("posting_date", resultSet.getDate(17));
                 record.put("posting_date_norm", resultSet.getDate(18));
                 record.put("posting_id", resultSet.getString(19));
                 record.put("due_date", resultSet.getDate(20));
                 record.put("due_date_norm", resultSet.getDate(21));
                 record.put("order_date", resultSet.getDate(22));
                 record.put("order_date_norm", resultSet.getDate(23));
                 record.put("invoice_id", resultSet.getInt(24));
                 record.put("invoice_id_norm", resultSet.getInt(25));
                 record.put("baseline_create_date", resultSet.getDate(26));
                 record.put("invoice_date_norm", resultSet.getDate(27));
                 record.put("total_open_amount", resultSet.getFloat(28));
                 record.put("total_open_amount_norm", resultSet.getFloat(29));
                 record.put("cust_payment_terms", resultSet.getInt(30));
                 record.put("business_area", resultSet.getString(31));
                 record.put("ship_date", resultSet.getDate(32));
                 record.put("ship_to", resultSet.getString(33));
                 record.put("clearing_date", resultSet.getDate(34));
                 record.put("clearing_date_norm", resultSet.getDate(35));
                 record.put("reason_code", resultSet.getString(36));
                 record.put("isOpen", resultSet.getInt(37));
                 record.put("discount_due_date_norm", resultSet.getDate(38));
                 record.put("debit_credit_indicator", resultSet.getString(39));
                 record.put("payment_method", resultSet.getString(40));
                 record.put("document_creation_date", resultSet.getDate(41));
                 record.put("invoice_amount_doc_currency", resultSet.getFloat(42));
                 record.put("document_id", resultSet.getInt(43));
                 record.put("actual_open_amount", resultSet.getFloat(44));
                 record.put("paid_amount", resultSet.getFloat(45));
                 record.put("dayspast_due", resultSet.getInt(46));
                 record.put("invoice_age", resultSet.getInt(47));
                 record.put("disputed_amount", resultSet.getFloat(48));
                 
                 setArrayList(record);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        
        
        getArrayList();
        
        setJsonData(getArrayList()); 
        getJsonData();
        System.out.println(getJsonData());
         
        return  "Success";
    }
    
    public void setJsonData(ArrayList<Object> arrayList) {
        Gson gson = new Gson();
        this.element = new JsonParser().parse(gson.toJson(arrayList));
        object.add("customerDetail", this.element);
        this.data = object.toString();
    }
    
    public String getJsonData() {
        return this.data;
    }
    
    public void setPreparedStatement(String value) {
            try {
                this.preparedStatement = conn.prepareStatement(value);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
    
    public PreparedStatement getPreparedStatement() {
        return this.preparedStatement;
    }
    
    public void setResultSet(PreparedStatement preparedStatement){
        try {
            this.resultSet = preparedStatement.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public ResultSet getResultSet() {
        return this.resultSet;
    }
    
    public void setArrayList(HashMap<String,Object> record) {
        arrayList.add(record);
        
    }
    
    public ArrayList<Object> getArrayList(){
        return this.arrayList;
    }

}

My Extjs code is:

var gridContainer = function() {
Ext.define('User', {
   extend: 'Ext.data.Model',
   fields: [
      'pkId',
           'acctDocHeaderId',
  'companyId',
  'documentNumber',
  'documentNumberNorm',
  'businessCode',
  'createYear',
  'documentLineNumber',
  'docType',
  'customerNumber',      
  'customerNumberNorm',      
  'fkCustomerMapId',
  'customerName',
  'division',
  'documentCreateDate',
  'documentCreateDateNorm',
  'postingDate',
  'postingDateNorm',
  'postingID',
  'dueDate',
  'dueDateNorm',
  'orderDate',
  'orderDateNorm',
  'invoiceID',
  'invoiceIDNorm',
  'baseLineCreateDate',
  'invoiceDateNorm',
  'totalOpenAmount',
  'totalOpenAmountNorm',
  'custPaymentTerms',
  'businessArea',
  'shipDate',
  'shipTo',
  'clearingDate',
  'clearingDateNorm',
  'reasonCode',
  'isOpen',
  'discountDueDateNorm',
  'debitCreditIndicator',
  'paymentMethod',
  'documentCreationDate',
  'invoiceAmountDocCurrency',
  'documentID',
  'actualOpenAmount',
  'paidAmount',
  'daysPastDue',
  'invoiceAge',
  'disputedAmount',
  ]
});

//number of items in a page
var itemsPerPage = 5

//user store
var userStore = Ext.create('Ext.data.Store', {
   model: 'User',
   pageSize: itemsPerPage,
   storeId: 'userStore',
   proxy: {
    type: 'ajax',
    url: 'generateCustomerJson',
   // url: 'http://localhost:8080/1705188/customerDataJsonCreator?value='.concat(),
    reader: {
        type: 'json',
        totalProperty: 'total',
        rootProperty: 'customerDetail',
    }
   },
   autoLoad: true
});
console.log(userStore);

//business store
var businessStore = Ext.create('Ext.data.Store', {
     storeId: 'businessStore',
     proxy: {
    type: 'ajax',
    url: 'http://localhost:8080/1705188/companyCodeJsonCreator',
    reader: {
    type: 'json',
    totalProperty: 'total',
rootProperty: 'customerCode'
    }
   },
   autoLoad: true
  });

//sending the data to the server
// userStore.load({
//params: {
//start: 0,
//limit: itemsPerPage,
//}
//});

//grid
Ext.create('Ext.grid.Panel', {
renderTo: Ext.get('ext-js-grid'),
   store: userStore,
   width: '100%',
   id: 'employee-list',
   title: 'List of Employees',
   selType: 'checkboxmodel',
   autoLoad: true,
   columns: [{
       text: 'Company ID',
       sortable: true,
       dataIndex: 'pk_id',
       flx: 3
   }, {
       text: 'Account Header ID',
       dataIndex: 'acct_doc_header_id',
       minWidth: 150
   }, {
    text: 'Document Number',
    dataIndex: 'document_number',
    minWidth: 150
   }, {
    text: 'Document Number Normalised',
    dataIndex: 'document_number_norm',
    minWidth: 250
   }, {
    text: 'Business Code',
    dataIndex: 'business_code',
    minWidth: 150
   }, {
    text: 'Create Year',
    dataIndex: 'create_year',
    minWidth: 150
   }, {
    text: 'Document Line number',
    dataIndex: 'document_line_number',
    minWidth: 300
   }, {
    text: 'Document Type',
    dataIndex: 'doctype',
    minWidth: 150
   },{
    text: 'Customer Number',
    dataIndex: 'customer_number',
    minWidth: 150
   },{
    text: 'Customer Number Normalised',
    dataIndex: 'customer_number_norm',
    minWidth: 350
   }, {
    text: 'Customer Map ID',
    dataIndex: 'fk_customer_map_id',
    minWidth: 150
   }, {
    text: 'Name Of Customer',
    dataIndex: 'customer_name',
    minWidth: 150
   }, {
    text: 'Division',
    dataIndex: 'division',
    minWidth: 150
   }, {
    text: 'Document Create Date',
    dataIndex: 'document_create_date',
    minWidth: 300
   }, {
    text: 'Document Create Date Normalised',
    dataIndex: 'document_create_date_norm',
    minWidth: 350
   }, {
    text: 'Posting date',
    dataIndex: 'posting_date',
    minWidth: 150
   }, {
    text: 'Posting Date Normalised',
    dataIndex: 'posting_date_norm',
    minWidth: 300
   }, {
    text: 'Posting ID',
    dataIndex: 'posting_id',
    minWidth: 150
   }, {
    text: 'Due In Date',
    dataIndex: 'due_date',
    minWidth: 150
   }, {
    text: 'Due In Date Normalised',
    dataIndex: 'due_date_norm',
    minWidth: 300
   }, {
    text: 'Order create Date',
    dataIndex: 'order_date',
    minWidth: 150
   }, {
    text: 'Order Create Date Normalised',
    dataIndex: 'order_date_norm',
    minWidth: 300
   }, {
    text: 'Baseline Date',
    dataIndex: 'baseline_create_date',
    minWidth: 150
   }, {
    text: 'Invoice Date',
    dataIndex: 'invoice_date_norm',
    minWidth: 150    
   }, {
    text: 'Invoice ID',
    dataIndex: 'invoice_id',
    minWidth: 150
   }, {
    text: 'Invoice ID Normalised',
    dataIndex: 'invoice_id_norm',
    minWidth: 250
   }, {
    text: 'Total Open Amount',
    dataIndex: 'total_open_amount',
    minWidth: 150
   },{
    text: 'Total Open Amount Normalised',
    dataIndex: 'total_open_amount_norm',
    minWidth: 350
   }, {
    text: 'Customer Payment Terms',
    dataIndex: 'cust_payment_terms',
    minWidth: 300
   }, {
    text: 'Area of Business',
    dataIndex: 'bsiness_area',
    minWidth: 150
   }, {
    text: 'Clear Date',
    dataIndex: 'clearing_date',
    minWidth: 150
   },{
    text: 'Clear Date Normalised',
    dataIndex: 'clearing_date_norm',
    minWidth: 350
   }, {
    text: 'Is Open Invoice',
    dataIndex: 'isopen',
    minWidth: 150
   }, {
    text: 'Shipping Date',
    dataIndex: 'ship_date',
    minWidth: 150
   }, {
    text: 'Shipping To',
    dataIndex: 'ship_to',
    minWidth: 150
   },{
    text: 'Reason Code',
    dataIndex: 'reason_code',
    minWidth: 150
   }, {
    text: 'Discount Due Date Normalised',
    dataIndex: 'discount_due_date_norm',
    minWidth: 300
   }, {
    text: 'Debit Credit Status',
    dataIndex: 'debit_credit_indicator',
    minWidth: 150
   }, {
    text: 'Payment Method',
    dataIndex: 'payment_method',
    minWidth: 150
   }, {
    text: 'Payment Amount',
    dataIndex: 'paid_amount',
    minWidth: 150
   }, {
    text: 'Days past Due date',
    dataIndex: 'dayspast_due',
    minWidth: 150
   }, {
    text: 'Doc Id',
    dataIndex: 'document_id',
    minWidth: 150
   }, {
    text: 'Document Create Date',
    dataIndex: 'document_create_date',
    minWidth: 350
   }, {
    text: 'Actual Amount Outstanding',
    dataIndex: 'actual_open_amount',
    minWidth: 350
   }, {
    text: 'Age of Invoice',
    dataIndex: 'invoice_age',
    minWidth: 150
   }, {
    text: 'Invoice Currency',
    dataIndex: 'invoice_amount_doc_currency',
    minWidth: 150
   }, {
    text: 'Dispute Amount',
    dataIndex: 'disputed_amount',
    minWidth: 150
   },],
   dockedItems: [{
    xtype: 'pagingtoolbar',
    store: 'userStore',
    dock: 'bottom',
    displayInfo: true
   }],
   buttons: [
    {
    text: 'Add',
       handler: function () {
           var userWindow = Ext.create('Ext.window.Window', {
               title: 'Add Invoice Details',
               height: 600,
               width: 600,
               layout: 'fit',
               bodyPadding: '8',
               items: {
                   xtype: 'form',
                   border: false,
                   defaultType: 'textfield',
                   items: [{
                       fieldLabel: 'Company Code',
                       name: 'companyCode',
                       id: 'companyCode',
                       xtype: 'combobox',
                       store: businessStore,
                       displayField: 'business_code',
                       queryMode: 'local',
                       filterPickList :true,
                       width: '100%',
                       labelWidth: 150,
                       allowBlank: false
                   }, , {
                       fieldLabel: 'Document Number',
                       name: 'documentNumber',
                       id: 'documentNumber',
                       width: '100%',
                       vtype: 'alphanum',
                       labelWidth: 150,
                       allowBlank: false
                   }, {
                       fieldLabel: 'Customer Name',
                       name: 'customerName',
                       id: 'customerName',
                       width: '100%',
                       labelWidth: 150,
                       vtype: 'alphanum',
                       allowBlank: false
                   }, {
                       xtype: 'numberfield',
                       fieldLabel: 'Invoice Id',
                       name: 'invoiceId',
                       id :'invoiceId',
                       width: '100%',
                       labelWidth: 150,
                       allowBlank: false
                   }, {
                       fieldLabel: 'Open Amount',
                       name: 'openAmount',
                       id: 'openAmount',
                       width: '100%',
                       labelWidth: 150,
                       disabled: true,
                       allowBlank: false
                   }, {
                       xtype: 'fieldcontainer',
                       fieldLabel: 'Is Open Invoice',
                       defaultType: 'radiofield',
                       id: 'isOpen',
                       layout: 'hbox',
                       labelWidth: 150,
                       allowBlank: false,
                       items: [{
                           boxLabel: 'Yes',
                           name: 'isOpenInvoice',
                           inputValue: 'y',
                           id: 'yesRadioButton',
                           flex: 1
                       }, {
                           boxLabel: 'No',
                           name: 'isOpenInvoice',
                           inputValue: 'n',
                           id: 'noRadioButton',
                           flex: 1
                       }]
                   },{
                       xtype: 'fieldcontainer',
                       fieldLabel: 'Payment Method',
                       defaultType: 'checkboxfield',
                       id: 'paymentMethod',
                       layout: 'hbox',
                       allowBlank: false,
                       labelWidth: 150,
                       items: [
                           {
                               boxLabel  : 'Check',
                               name      : 'paymentMethod',
                               inputValue: '1',
                               id        : 'checkCheckBox',
                               checked   : true,
                               flex: 1
                           }, {
                               boxLabel  : 'ACH',
                               name      : 'paymentMethod',
                               inputValue: '2',
                               id        : 'achCheckBox',
                               flex: 1
                           }, {
                               boxLabel  : 'Online',
                               name      : 'paymentMethod',
                               inputValue: '3',
                               id        : 'onlineCheckBox'
                           }
                       ]
                   }, {
                       fieldLabel: 'Payment Amount',
                       name: 'paymentAmount',
                       id: 'paymentAmount',
                       width: '100%',
                       labelWidth: 150,
                       disabled: true
                   }, {
                       fieldLabel: 'Division',
                       name: 'division',
                       id: 'division',
                       width: '100%',
                       labelWidth: 150,
                       emptyText: 'Enter Division Email Id',
                       vtype: 'email'
                   }],
                   dockedItems: [{
                       xtype: 'toolbar',
                       dock: 'bottom',
                        layout: {
                       type: 'hbox',
                       align: 'center',
                       pack: 'middle'
                   },
                       items: [{
                           xtype: 'button',
                           text: 'Save',
                           formBind: true,
                           disabled: true,
                           handler: function() {
                               var form = this.up('form').getForm().getValues();
                               console.log(form);
                               Ext.Ajax.request({
                                url: 'http://localhost:8080/1705188/addInvoice',
                                method: 'GET',
                                params: {
                                company_id: Ext.getCmp('companyCode').getValue(),
                                document_number: Ext.getCmp('documentNumber').getValue(),
                                customer_name: Ext.getCmp('customerName').getValue(),
                                invoice_id: Ext.getCmp('invoiceId').getValue,
                                total_open_amount: Ext.getCmp('openAmount').getValue(),
                                isOpen: Ext.getCmp('yesRadioButton').getValue(),
                                payment_method: Ext.getCmp('checkCheckBox').getValue(),
                                paid_amount: Ext.getCmp('paymentAmount').getValue(),
                                division: Ext.getCmp('division').getValue()
                               },
                               success: function(){
                                Ext.Msg.alert('Saved','Your data has been added');
                                Ext.getCmp('employee-list').getView().refresh();
                               },
                               failure: function(){
                                Ext.Msg.alert('Error','Your data could not be saved');
                               }
                               });
                               userWindow.close();
                           }
                       }, {
                           xtype: 'button',
                           text: 'Cancel'
                       }],
                       
                   }]
               }
           });

           userWindow.show();
       }
   }]
});
};

Ext.onReady(gridContainer);

My console output in Eclipse is:

{"customerDetail":[{"total_open_amount_norm":0.0,"pk_id":1,"customer_number":228448,"business_code":"Faes6","posting_id":"","document_id":544073954,"customer_number_norm":228448,"invoice_age":78,"division":"","reason_code":"","acct_doc_header_id":544073954,"dayspast_due":18,"debit_credit_indicator":"","invoice_id":48289611,"document_line_number":-1,"document_create_date":"Apr 15, 2019","document_create_date_norm":"Apr 15, 2019","payment_method":"","clearing_date":"Jul 2, 2019","document_number":48289611,"company_id":60,"total_open_amount":0.0,"clearing_date_norm":"Jul 2, 2019","fk_customer_map_id":-1,"business_area":"","document_number_norm":48289611,"doctype":"RI","cust_payment_terms":60,"isOpen":0,"invoice_id_norm":48289611,"create_year":"","actual_open_amount":8166.52,"paid_amount":8166.52,"disputed_amount":0.0,"customer_name":"Fatboy Industries","ship_to":"","invoice_amount_doc_currency":8166.52},{"total_open_amount_norm":0.0,"pk_id":2,"customer_number":228089,"business_code":"cvrp1","posting_id":"","document_id":540062945,"customer_number_norm":228089,"invoice_age":56,"division":"","reason_code":"","acct_doc_header_id":540062945,"dayspast_due":-4,"debit_credit_indicator":"","invoice_id":40134128,"document_line_number":-1,"document_create_date":"Aug 3, 2018","document_create_date_norm":"Aug 3, 2018","payment_method":"","clearing_date":"Sep 28, 2018","document_number":40134128,"company_id":60,"total_open_amount":0.0,"clearing_date_norm":"Sep 28, 2018","fk_customer_map_id":-1,"business_area":"","document_number_norm":40134128,"doctype":"RI","cust_payment_terms":60,"isOpen":0,"invoice_id_norm":40134128,"create_year":"","actual_open_amount":5027.5,"paid_amount":5027.5,"disputed_amount":0.0,"customer_name":"cvMaker corp","ship_to":"","invoice_amount_doc_currency":5027.5},{"total_open_amount_norm":0.0,"pk_id":3,"customer_number":228098,"business_code":"skes8","posting_id":"","document_id":537291313,"customer_number_norm":228098,"invoice_age":53,"division":"","reason_code":"","acct_doc_header_id":537291313,"dayspast_due":-7,"debit_credit_indicator":"","invoice_id":36548810,"document_line_number":-1,"document_create_date":"Mar 13, 2018","document_create_date_norm":"Mar 13, 2018","payment_method":"","clearing_date":"May 5, 2018","document_number":36548810,"company_id":60,"total_open_amount":0.0,"clearing_date_norm":"May 5, 2018","fk_customer_map_id":-1,"business_area":"","document_number_norm":36548810,"doctype":"RI","cust_payment_terms":60,"isOpen":0,"invoice_id_norm":36548810,"create_year":"","actual_open_amount":270.0,"paid_amount":270.0,"disputed_amount":0.0,"customer_name":"skynetpwc softwares","ship_to":"","invoice_amount_doc_currency":270.0},{"total_open_amount_norm":0.0,"pk_id":4,"customer_number":218997,"business_code":"nuus8","posting_id":"","document_id":539694838,"customer_number_norm":218997,"invoice_age":63,"division":"","reason_code":"","acct_doc_header_id":539694838,"dayspast_due":3,"debit_credit_indicator":"","invoice_id":39579444,"document_line_number":-1,"document_create_date":"Jul 11, 2018","document_create_date_norm":"Jul 11, 2018","payment_method":"","clearing_date":"Sep 12, 2018","document_number":39579444,"company_id":60,"total_open_amount":0.0,"clearing_date_norm":"Sep 12, 2018","fk_customer_map_id":-1,"business_area":"","document_number_norm":39579444,"doctype":"RI","cust_payment_terms":60,"isOpen":0,"invoice_id_norm":39579444,"create_year":"","actual_open_amount":158.94,"paid_amount":158.94,"disputed_amount":0.0,"customer_name":"nucleus","ship_to":"","invoice_amount_doc_currency":158.94},{"total_open_amount_norm":0.0,"pk_id":5,"customer_number":226550,"business_code":"syps7","posting_id":"","document_id":537094052,"customer_number_norm":226550,"invoice_age":62,"division":"","reason_code":"","acct_doc_header_id":537094052,"dayspast_due":2,"debit_credit_indicator":"","invoice_id":36266913,"document_line_number":-1,"document_create_date":"Mar 1, 2018","document_create_date_norm":"Mar 1, 2018","payment_method":"","clearing_date":"May 2, 2018","document_number":36266913,"company_id":60,"total_open_amount":0.0,"clearing_date_norm":"May 2, 2018","fk_customer_map_id":-1,"business_area":"","document_number_norm":36266913,"doctype":"RI","cust_payment_terms":60,"isOpen":0,"invoice_id_norm":36266913,"create_year":"","actual_open_amount":5962.81,"paid_amount":5962.81,"disputed_amount":0.0,"customer_name":"system ops","ship_to":"","invoice_amount_doc_currency":5962.81}]}

And the error I am getting on the browser while running the server is: Output of the project

Any help would be appreciated.
Edit:
I actually figured out the root of the error. My struts2 action class is not returning the json data and hence, extjs is not able to decode it. I am fairly new to struts2, so I dont know how to do that.
Edit:
My error was resolved. Thanks for the help.
Actually, problem was in my struts.xml file.
Edited struts.xml file is given below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
   "http://struts.apache.org/dtds/struts-2.5.dtd">

<struts>
    <package name="default" extends="json-default">
        <action 
            name = "generateCustomerJson" 
            class = "com.proj.Action.CustomerDataJsonCreator">
            <result name = "Success" type="json">
                <param name = "root">arrayList</param>
            </result>
        </action>
    </package>
</struts>

Emperor
  • 11
  • 4
  • Additionally, could anyone also explain me the data flow / control flow from extjs to struts2. I would be very thankful. – Emperor Jul 24 '20 at 08:43
  • The framework has support for json via plugin. You may be missing [some](https://stackoverflow.com/a/47964971/573032) point in the configuration. – Roman C Jul 25 '20 at 18:51
  • Hey Roman! Thanks for the reply. However, I already have the json plugin jar in my environment. – Emperor Jul 26 '20 at 06:30
  • The plugin is only one piece of cake. The linked answer explains how to serialize fields when json object is created. – Roman C Jul 29 '20 at 05:23

2 Answers2

0

enter image description here You have forgotten the rootProperty in the store`s proxy and in your json. I have changed your code a little bit in the fiddle, it works with dummy jsons.

FIDDLE

About the code It is better to split the code to models, stores and different views. The files must be as small as possible. (What can be class must be class). For example the popup window better to define in separate class (as it is done in fiddle sample). Even the toolbars of grid and popup window must be defined in separate classes.. Your grid columns has the same properties, it is better to move them in the 'defaults' config property of the grid ( I have moved the labelWith: 150 there)..

Arthur Rubens
  • 4,626
  • 1
  • 8
  • 11
  • Hey, Arthur! Thanks for the response.I will note the advice provided by you. However, I am unable to run the code using struts2 and thus the error. On using servlets, I am able to run the extjs code perfectly. – Emperor Jul 24 '20 at 15:21
  • Look in the stores (Users and business..), there must be “rootProperty”, it is missing, In another store is missing the model. Fix your JSON, it must not be just an array of objects, it must be an object, have a look at the provided fiddle example. The error is in the stores config and json format. – Arthur Rubens Jul 24 '20 at 15:30
  • 1
    Will sure look into the fiddle provided by you. Thanks a lot for the help. – Emperor Jul 24 '20 at 16:19
  • Hey Arthur. I went through the solution you provided. The folder structure is pretty neat. However, while running the code, I got another error called Cannot read property 'prototype' of undefined at constructor.applyMainView. Shall I provide the whole error? And can you explain me why do we get this error? – Emperor Jul 25 '20 at 14:55
  • It is standard extjs folder structure.. nothing new. – Arthur Rubens Jul 25 '20 at 15:04
  • Okaay! But can you explain me this error? – Emperor Jul 25 '20 at 15:13
  • No, I have never seen such error. Maybe you have not included some classes.. – Arthur Rubens Jul 25 '20 at 15:15
  • Hey Arthur! Apart from the folder structure, I have changed everything you asked. However, I am still getting the same error. Any idea about the error? – Emperor Jul 26 '20 at 12:46
  • Changed? Don‘t you use sencha cmd? https://www.extjs-tutorial.com/extjs/sencha-cmd – Arthur Rubens Jul 26 '20 at 12:54
  • Aah. Sorry Arthur. But I don't use sencha cmd. I, actually, have got all the plugins downloaded and included in my .jsp file. – Emperor Jul 26 '20 at 22:26
  • It is better to to sencha cmd for building the project. Have a look at the sencha docs. – Arthur Rubens Jul 27 '20 at 09:06
  • Sure! Will look into it. – Emperor Jul 27 '20 at 11:55
0

I was able to get the solution. After days of lookup, I found problem in my struts.xml file. The corrected file is attached in the question itself. Thanks for all the help!

Emperor
  • 11
  • 4