Grails: Carry forward params on g:actionSubmit is clicked

1.7k views Asked by At

How to carry forward the parameters when g:actionSubmit button is clicked?

Here is my gsp code:

<g:checkBox name="msgCheck" checked="" value="${userInstance.emailId}"></g:checkBox>
...
<g:actionSubmit class="update" action="delete" value="Delete" params="${params}"></g:actionSubmit>

Here is my controller code:

def delete() {
    try {
        def user_list = params.msgCheck

        //deleting the user
        //successful.

        redirect(action: "list", params: params)
    } catch (Exception e) {
        log.error("Deleted Exception---->>" + e.getMessage())
    }
}

redirect is missing with params. I wanted to carry forward params on redirect.

The URL before I clicked on 'delete' g:actionSubmit button looks like:

http://localhost:8080/message/list?offset=10&max=100

After 'delete' g:actionSubmit button is clicked, the url looks like (and has extra parameters:

 http://localhost:8080/message/list?msgCheck=ga12%40user.com&msgCheck=&_action_domainDelete=Delete&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&_msgCheck=&domainId=1&noofrows=100

How do I carry forward the parameter when g:actionSubmit button is clicked?

1

There are 1 answers

1
MKB On BEST ANSWER

I don't think that you can pass params with actionSubmit in this way. You can use params attribute of g:form tag, like

<g:form params="${params}">
    ...
</g:form>

or

<g:form params="[offset: params.offset, max: params.max]">
    ...
</g:form>