Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid extra parameters in grails (GSP page to Controller)

I am new with grails. In my web application I have a hidden field

<g:hiddenField name="tags" id="tags" value=""></g:hiddenField>

value of this hidden field is setting on Submit.

<input type="submit" class="btn btn-default" onclick="setTag()" value="Ask Question"/>

and setTag method is defined as : function setTag() { $("#tags").val(selectedTagList); }

selectedTagList is a List of Ids.

when ever going to controller, if the value sending is 1,2,3 and in controller the value reach as [1,2,3, , ]

if it is a,b then the value reach as [a,b, , ] two extra parameters are receiving in controller. How can i avoid this extra parameters. ??

like image 633
JayKay Avatar asked Dec 02 '25 10:12

JayKay


1 Answers

I've test your situation. It's a quite strange. There is empty value in controller via getting params variable. But, its normally with TextField. So, I think the first step, you should try to remove empty value in the list via this statement :

def clean = list.findAll { item -> item != ''}
like image 106
Phat H. VU Avatar answered Dec 04 '25 06:12

Phat H. VU



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!