سؤال

I have the unenviable task of editing a 2000 line javascript file inorder to maintain and add some new feature to a web app written in JSP, Json-RPC, jQuery and Java. I do not possess any deeper knowledge of jQuery and Json-RPC except basic Javascript knowledge and the original developer is not there anymore. There is a JS function which accepts a few params, and calls a Json-RPC and here I am getting the error

arg 1 could not unmarshal

Can someone please tell me what this error means?

Here is my code

function distributeQuantityNew(pReportId, pDecimalPlaces, pRun) {
try {
    alert('distributeQuantityNew: ' + pReportId + ', ' + pDecimalPlaces + ', ' + pRun);
    var fieldValue = $("#distribution_quantity_" + pReportId).val();
    if (fieldValue.length == 0) {
        showErrorDialog(resourceBundleMap["error.no.distribution.quantity"]);
        return;
    } else {
        $("#distribution_quantity_" + pReportId).val("");
    }

    var affectedRowIds = [];
    var rows = $("#tableBody_" + pReportId + " tr:visible").has("input[type=text]").filter(function(index) {
            var voucherType = this.cells[getVoucherColumnIndex()].innerHTML;
            if ((voucherType == 'TRANSFER_CS') || (voucherType == 'PAYOUT_CS') || (voucherType == 'SOURCE_BON') || (voucherType == 'PAYOUT_BON')) {
                return false;
            }
            affectedRowIds.push(parseInt(this.id.split("_")[3]));
            return true;
        }
    );

    var affectedReportRows = $.extend(true, {}, foreignReportMap[pReportId]);
    $.each(affectedReportRows.map, function(i, row) {
        if ($.inArray(row.partnerReportBillNr, affectedRowIds) == -1) {
            delete affectedReportRows.map["row_" + row.partnerReportBillNr];
        }
    });

    var report = getLoadedReportByRunId(pReportId);
    var productType = report.partnerProductType;

    SessionManager.extend();
    var resultRows = jsonrpc.foreignReportObject.distributeQuantity(affectedReportRows, fieldValue, pDecimalPlaces, pRun);
    alert('back after RPC');
    $.each(resultRows.map, function(i, row) {
        foreignReportMap[pReportId].map["row_" + row.partnerReportBillNr] = row;
        updateForeignReportRow(row, true, productType);
    });

    updateSummaryRow(pReportId);
    toggleApproveAllLink(pReportId);

    sortForeignReportTable(pReportId, true);
} catch (e) {
    handleError("Failed to distribute quantity: ", e);
}

}

I have peppered it with alerts so that I know whether RPC call was succesful, but I get the error arg 1 could not unmarshal before that from the catch block. Thanks for any hints

هل كانت مفيدة؟

المحلول

OK, got it solved. The first parameter to the remote function is expecting a list of Map<String, SomeBO>. SomeBO is a bean with several BigDecimals. I had another JS function which had set the values passed into the Map. This function was setting a BigNumber where I had a setter of String only. I wish the error I had gotten back from JSON unmarshaller was a bit more descriptive...Below is the code where I added .toString() to solve the issue

    foreignReportMap[pReportId].map["row_" + pRowId].clientQuantity =     clientQuantity.toString();
foreignReportMap[pReportId].map["row_" + pRowId].totalClientQuantity = totalClientQuantity.toString();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top