Could not get value from controller using command object

This my GSP form

 <g:form action="saveDP" method="POST">
        <input type="hidden" value="${this.agent}" name="agent">
        <g:submitButton name="create" class="btn btn-success" value="Add" />
 </g:form>

This my controller

def saveDP(DepositoryParticipant depositoryParticipant) {
    println "agent = " + depositoryParticipant.agent
}

This is from source html

<form action="/cds/agent/saveDP" method="post" >
        <input type="hidden" value="Depository Participants" name="agent">
        <input type="submit" name="create" class="btn btn-success" value="Add" id="create" />
 </form>

This is result in console

agent = null

I am trying to use command object. The value is null. How to get value?

  • How to exclude gsps from being compiled by compileGroovyPages gradle task?

    I have multi build grails 3 project. mainApp and a plugin.

    I am writing a plugin having controllers and views(gsp)(similar name package of mainApp). I want plugin to override the mainApp source files.

    How can I exclude mainApp gsp files from being compiled, so plugin files work.

    I tried multiple combination of exclude in build.gradle, but no luck.

    sourceSets{
        main{
            resources{
                exclude '/contract/plugin.gsp'
                exclude 'plugin.gsp'
            }
        }
    }
    
    compileGroovyPages {
        exclude 'contract/**'
        exclude '/contract/plugin.gsp'
        exclude 'plugin.gsp'
        exclude '*contractplugin.gsp'
        exclude 'contract/plugin.gsp'
        exclude '**/plugin.gsp'
        exclude '**/plugin.gsp*'
        exclude 'grails-app/views/contract/plugin.gsp'
        exclude 'contract/**'
        exclude '../views/contract/**'
        exclude { FileTreeElement elem -> (elem.path.contains('/contract/'))}
    }
    

    Can someone help? Or if they have other approach to this problem( where plugin source is given preference on mainApp)