Utilizing JavaScript Objects within DWR Method Invocation

Having trouble passing a JavaScript Object to the server side using a DWR method call and encountering a JS error.

Here is the JavaScript code:

var referenceFieldValues = new Object();
var refFieldArray = referenceFields.split(",");
for(var i=0;i<refFieldArray.length;i++ ){
    referenceFieldValues[refFieldArray[i]] = $("#"+refFieldArray[i]).val();
}
DWRRequesthandler.method(fieldId,refObjectId,searchField,searchText,referenceFieldValues,callback);

And the corresponding Java Code :

public JSONObject method(String fieldId, String refObjectId,String searchField, String searchString, Object referenceFieldValues,HttpServletRequest request,HttpServletResponse response){
//some code..
}

The request fails to reach the server and DWR throws an error. The populated value of referenceFieldValues is shown as:

Object { AB_SUP_COM="12345"}

Any assistance would be greatly appreciated.

Answer №1

After some trial and error, I was able to figure out the solution on my own.

All it took was swapping Object referenceFieldValues with Map referenceFieldValues in my code, and everything started working smoothly.

Thanks to lilith for offering their input as well!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing JPA 2.1 to link EnumSet to mysql Set in Mapping

Is there a way to store EnumSet in a MySQL column with the type set? @Data @Entity @Table(name = "ENTITY_TABLE") public class Entity implements Serializable { @Id @GeneratedValue @Column(nullable = false) @NotNull private String id; @Column( ...

Avoid Updating State After Adding Row in material-table

When utilizing the material-table library, my goal is to display a different component upon adding a row. Although the code functions as expected, I encountered the following error in the console: Warning: Can't perform a React state update on an unm ...

Is it possible to modify the location of my CSG object prior to performing subtraction in Threejs with ThreeCSG?

Looking to carve out specific "voids" in platforms using ThreeCSG. The goal is to have these voids positioned at particular locations on the larger platform. var geometry = new THREE.CubeGeometry( 500, 10, 500 ); var hole_geometry = new THREE.CubeGeom ...

Can Ajax and WAMP Server work together?

After spending a considerable amount of time going back and forth on Google, I couldn't figure out why my AJAX was not refreshing the content beyond its initial load. Frustrated, I decided to give up and write a lengthy post here seeking help. However ...

Activate the function only once the display has finished rendering all items from ng-repeat, not just when ng-repeat reaches its last index

Currently, I am generating a list using ng-repeat and each iteration is rendering a component tag with a unique id based on the $index value. The implementation looks like this: <div ng-if="$ctrl.myArr.length > 0" ng-repeat="obj in $ctrl.myArr"> ...

Removing items in vue.js

I'm currently in the process of learning Vue.js. This is my first attempt at creating a small to-do application, and I am encountering issues with deleting each individual task upon clicking. Despite watching multiple YouTube tutorials, I have not bee ...

When using res.render to send results, redundant lines are displayed

I feel like I must be missing something really obvious, but for the life of me I cannot figure out what it is. All I want to do is list the documents in a MongoDB collection in a straightforward manner. I am working with nodejs, mongoose, and Jade (althoug ...

Changing states in next.js is not accomplished by using setState

Struggling to update the page number using setCurrentPage(page) - clicking the button doesn't trigger any state change. Tried various methods without success. Manually modified the number in useState(1) and confirmed that the page did switch. import ...

Navigating through the keys of a parameter that can assume one of three distinct interfaces in TypeScript: a guide

Here is a function example: function myFunc(input: A | B | C) { let key: keyof A | keyof B | keyof C; for(key in input) { let temp = input[key]; console.log(temp); } } The definitions for A, B, and C are as follows: interfa ...

Building a Dynamic Web App with PHP and Vue.js

I developed an API using PHP and you can access it through this link: However, I encountered an issue when trying to display the data on the front-end of my Vue.js (Home.vue) file using axios. Below is the code I used: <ul class="ta-track-list" v-if= ...

Renaming and destructuring of an array's length using ReactJS

I am working with a reduce function shown below: let el = scopes.reduce ((tot, {actions}) => tot + actions.length, 0); I attempted to modify it as follows, but it appears that this is not the correct approach: let el = scopes.reduce ((tot, {actions.l ...

Transitioning from traditional Three.js written in vanilla JavaScript to React Three Fiber involves a shift in

I am currently faced with the task of converting a vanilla JS Three.js script to React Three Fiber. import * as THREE from 'three'; let scene, camera, renderer; //Canvas const canvas = document.querySelector('canvas') //Number of lin ...

Struggle with comparing strings in different cases

When utilizing the "WithText" function within a Testcafe script, it appears to be case-sensitive. How can I modify it to be case-insensitive? For example, allowing both "Myname" and "myname" for a user input. It's problematic when a script fails due t ...

What is the best way to retrieve a list of unchecked checkboxes in a Razor Page model?

Currently, I am working on a razor page using .NET Core 7. I have encountered an issue where I am unable to pass values of 1, 2, and 3 for unchecked checkboxes from the HTML page to the page model in the post method. When the user clicks the submit button ...

Is there a method for accessing PHP POST data from external sources?

Alright, so listen up. I've been playing around with RFID technology lately. To put it simply, the RFID reader is able to transmit data from tags to an HTML page as a data stream via POST. Let's say there's a page called datastream.php that ...

Accept only hexadecimal color codes as user input

How can I create a variable in JavaScript that only accepts color codes such as rgba, hashcode, and rgb? I need a solution specifically in javascript. ...

Angular 2: Dynamically Adjusting View Components Based on URL Path

Apologies for the unconventional title. I struggled to come up with a better one. My goal is to develop an application with a simple 3-part structure (header / content / footer). The header should change based on the active route, where each header is a s ...

Combining two arrays with varying lengths based on their values

Seeking assistance with a programming task that is straightforward yet challenging for me. There are two arrays: one long and one short. var arrayShort = [ { id: 'A', name: 'first' },{ id: 'B', name: &ap ...

Passing a selected value from the child to the parent component through state in React using hooks

I'm currently working on a Dropdown component that includes a select tag. When the user changes the value in the select, the state is updated to reflect the selected option. The StyledDropdown component is used for styling the select element. const D ...

Updating a JsonObject to another JsonObject in Java: A Step-by-Step Guide

Currently, I am working with a JSON file located at "D://test.json" and it adheres to the MongoDB formatting guidelines: { "key":"value" } { "embedded": { "key2": "value2" } } { "array" : ["one", "two", "three"] } My goal is to switch out one JsonObjec ...