I'm quite new to Grails and I've modified some previously existing button functionality so that it now should send 2 parameters to the controller. By the help of this tutorial I've written:
gsp:
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h4 class="modal-title">Some Title</h4></div>
<div class="modal-body">
<g:form>
<div class="input-group">
<span class="input-group-addon">Parameter 1</span>
<g:textField name="parameter1" size="24" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">Parameter 2</span>
<g:textField name="parameter2" size="24" class="form-control" />
</div>
<g:actionSubmit action="myAction" value="Go" class="btn btn-success"
data-toggle="tooltip" data-placement="top"
title="${grailsApplication.config.myTitle}" />
</g:form>
</div>
</div>
</div>
</div>
MyController:
// Though it is not mentioned in the tutorial, I've added 2 class properties.
// Otherwise I'd get a groovy.lang.MissingPropertyException
def parameter1
def parameter2
def myAction = {
doSomething(parameter1, parameter2)
}
// previously :
// def myAction = {
// doSomething()
// }
The two parameters are 'null' when the method is invoked. What can I do to make the parameters being handled to the controller method?
File names, imports and things alike should not be the problem here as the call of the function does well without parameters. The modal is new to the code as it is used to get the values of parameter1 and parameter2. The modal itself works well, as long as the parameters are not in the signature of the controller's method.
I've tried "grails clean" according to this answer. Grails version 2.5.4
try with this
// def parameter1 // you do not need this
// def parameter2 // you do not need this
def myAction = {
doSomething(params.parameter1, params.parameter2)
}