ncc1701e
ncc1701e

Reputation: 83

List when sent to Controller from GSP is a String?

I have a List of Strings built using Javascript on the client side which looks like this in the Javascript console:

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

I send this to my Controller as one of the params from my GSP in an ajax call but the controller sees it like this:

No address provided.,No telephone number provided.

i.e. as a String (without square brackets). This is how I am sending my params:

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

Any way so that the Controller will see it as a List and not a String?

Upvotes: 1

Views: 168

Answers (2)

user3914536
user3914536

Reputation:

Try this in your controller:

def redIssuesRemoved = params.redIssuesRemoved.tokenize(",")
def yellowIssuesRemoved = params.yellowIssuesRemoved.tokenize(",")

Upvotes: 1

Madhu Bose
Madhu Bose

Reputation: 371

Am guessing both red or yellow issues are you list of string params. So Try def listOfRedIssue = params.list('redIssuesRemoved') .. this makes it as List or yellowIssues

Upvotes: 1

Related Questions