Home Grails form g:textField parameters to Controller
Reply: 0

Grails form g:textField parameters to Controller

user2501 Published in March 23, 2018, 9:06 am

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:


<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">&times;</button><h4 class="modal-title">Some Title</h4></div>
            <div class="modal-body">
                    <div class="input-group">
                        <span class="input-group-addon">Parameter 1</span>
                        <g:textField name="parameter1" size="24" class="form-control" />
                    <div class="input-group">
                        <span class="input-group-addon">Parameter 2</span>
                        <g:textField name="parameter2" size="24" class="form-control" />
                    <g:actionSubmit action="myAction" value="Go" class="btn btn-success"
                                    data-toggle="tooltip" data-placement="top"
                                    title="${grailsApplication.config.myTitle}" />


// 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

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.527289 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO