Is a String the data type of a list when passed to the Controller from GSP?

Within my Javascript code on the client side, I have constructed a List of Strings that appears in the Javascript console like this:

["No address provided.", "No telephone number provided."]

When I send this data to my Controller as one of the parameters from my GSP using an ajax call, the controller interprets it differently:

No address provided.,No telephone number provided.

It sees the list as a single string without the square brackets. Here is how I am passing the parameters:

<button id="save" onclick = "${remoteFunction(controller: 'customer', 
                                                action: 'saveModifiedIndividualRecord',
                                                params: '\'uniqueId=\' + uniqueId + \'&secondaryId=\' + secondaryId + \'&redIssuesRemoved=\' + removedRedIssues + \'&yellowIssuesRemoved=\' + removedYellowIssues')}"> Save </button>

Is there any way to ensure that the Controller recognizes the input as a List and not just a String?

Answer №1

Here is a suggestion for handling this in your controller:

Extract the removed red and yellow issues from the parameters by splitting them into arrays:
def redIssuesRemoved = params.redIssuesRemoved.tokenize(",")
def yellowIssuesRemoved = params.yellowIssuesRemoved.tokenize(",")

Answer №2

My assumption is that both red or yellow problems are included in your list of string parameters. Consider using def listOfRedIssue = params.list('redIssuesRemoved') to make it a List of either red or yellow issues.

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

Animated div positioned on top of an image map

My current project can be found at: (please note that the sounds will not autoplay in the future). I am attempting to incorporate the sun effect from this codepen: https://codepen.io/Hackroro/pen/ByrKLZ I have realized that in order for the sun to appea ...

Retrieving the value of the button with $(this).val() is the only function that newusername performs

My issue arises when trying to send my data to a PHP file; it only sends the value of the <button> or <input type="button">. If I remove the variable definitions, it will only send the data as a string if they are formatted like this: newuser ...

Tips for simultaneously hovering over SVG and text elementsFeel free to hover over both SVG

After importing an SVG image and creating a box containing both an icon and text, I noticed that when hovering over the box, only the color changes to yellow while the SVG remains unaffected. How can I resolve this issue so that both the text and icon chan ...

Managing iframe scrolling using the parent window's scrollbar

I am currently working on an iframe to be utilized across various domains. The functionality of this iframe involves displaying a data list that updates when the bottom of the scroll is reached. An issue I encountered is that the parent window, where the ...

The art of properly indenting coffee script code

I encountered an indentation error in these lines Are there any online validators that can assist me? showAliveTests : (pageIndex, statusFilter) -> data= pageIndex:pageIndex status:statusFilter $.ajax u ...

CORS error: 405 Method Not Allowed despite having the correct headers (I believe)

I could use another set of eyes on this. My preflight request is returning a 405 Method Not Allowed error. After reviewing, everything seems to be in order. Here's the request: OPTIONS http://diffDomain/spf/v1/user/<a href="/cdn-cgi/l/email-prote ...

Ensuring the accuracy of a single field within a form containing multiple fields is made possible through the utilization of

I am facing an issue with my emailValidation method. Even though I want it to run when this.$refs.editUserForm.validate('email') returns true, it always seems to return false, especially when a valid email like <a href="/cdn-cgi/l/email-protec ...

Using the concept of method chaining in JavaScript, you can easily add multiple methods from

Hey there! I'm looking for some assistance with dynamically building a method chain. It seems like it should be pretty straightforward if you're familiar with how to do it... Currently, I am using mongoose and node.js to query a mongo database. ...

Issue with jQuery functionality when page is loaded through AJAX request

My index page currently has jQuery and a js file for a slider plugin loaded. I am using an on click event to load an external page using .load. Here is the code snippet: //jQuery loaded from Google CDN here (in head) jQuery( document ).ready(function() { ...

Unable to retrieve the value of a key from a node object

I'm baffled by how this is even possible For example, when I execute this code: console.error(order.Items[i]); The output is: { ItemURL: '', IsBundle: false, GiftTaxPrice: '0', GiftPrice: '0', GiftNotes: null ...

Vue: Clear the current form selection with a button click

<b-row class="mb-3"> <b-col> <div class="float-right"> <b-form-select v-model="selected" :options="options" ></b-form-select> ...

Unique Shader - Three.js

I have been attempting to implement a custom shader in Three.js, following various examples, but I am encountering issues. Below is the code snippet I have been working with: var vertex = "void main(){vec4 mvPosition = modelViewMatrix * vec4( position, 1. ...

Change the flyout menu to activate once clicked instead of when the mouse hovers over

Want to add a cool flyout menu action that triggers on click instead of mouseover? The current code triggers the flyouts on mouseover, but I need them to open only when clicked. Specifically, I'd like to change the functionality so that you click on a ...

Displaying PDF files on the internet without allowing them to be downloaded

How can I display PDF files on my website without allowing them to be saved or downloaded? Is there a way to prevent browsers from saving or downloading the PDF files? ...

Retrieve item from sessionStorage Cart

Greetings to the Stack Overflow community! I've often relied on Slack for valuable information and found solutions to many of my questions. However, this time, I'm facing a challenge that has me stumped. While I'm not an expert in JavaScript ...

What is the code for a non-breaking space in a JavaScript string?

It seems that this code is not functioning as expected: text = $td.text(); if (text == '&nbsp;') { text = ''; } Could it be related to a non-breaking space or the ampersand causing issues in JavaScript? ...

What is the best method for creating a fade effect on a div background?

I am trying to animate a div with the id #test from a 0 opacity background to an opacity of 0.7 using CSS rgba values, but for some reason, the .animate function is not working as expected. Here is my CSS: #test { background-color: rgba(0, 0, 0, 0); ...

When attempting to print the elements of an array, an "undefined" value unexpectedly appeared

I recently wrote a Javascript code to display a list of items, but for some reason an unexpected undefined text is appearing before the ordered list. I am quite puzzled as to why this issue is occurring. I am wondering if there is a variable that has not ...

The Angular component router-outlet is not recognized as a known element

I have encountered an error message: 'router-outlet' is not a known element: 1. If 'router-outlet' is an Angular component, then verify that it is part of this module. 2. If 'router-outlet' is a Web Component then add ...

ReactJs Error: Unable to access property value because it is undefined (trying to read '0')

I am currently attempting to retrieve and display the key-value pairs in payload from my JSON data. If the key exists in the array countTargetOptions, I want to show it in a component. However, I am encountering an error message stating Uncaught TypeError ...