I have a multiple select variable posting to controller. The way multiple select works is that it is passed as a single String if there was only one value selected and as a String[] if more than one values selected. I want to keep processing simple and treat the passed value(s) the same. So the best way I can up with is to convert it to List like so:
def selectedValues = params.selectedValues
List valuelist = new ArrayList()
if(selectedValues instanceof String) {
valuelist.add(selectedValues)
} else {
valuelist = selectedValues as List
}
It works but I am curious if there is a groovier way to do this, maybe with a one liner :).
Of course if I simply do:
List valuelist = selectedValues as List
It will not work for a single selected value as it will convert it from lets say 24 to [2,4]
Any ideas?