xSlok
xSlok

Reputation: 599

Grails - Button that calls a controller's method?

is there a way to call a method from a controller using a button? i did this:

<g:form controller="aluno" action="pesquisar"><input type="submit" value="Pesquisar"></g:form>

it worked, but, is there another way?

Upvotes: 2

Views: 3210

Answers (3)

ceid-vg
ceid-vg

Reputation: 333

An alternative, you can use a button in place of an input:

<g:link controller="yourcontroller" action="yourfunction">
    <button type="button">Press me!!!</button>
</g:link>

Upvotes: 0

Kamal kannan
Kamal kannan

Reputation: 253

Try this.

<g:link class="btn btn-info btn-sm" action="pesquisar" resource="${instance}">TRY IT</g:link>

Note : When you click try it Button it will automatically get controller which you currently used.

Upvotes: 0

rvargas
rvargas

Reputation: 635

You can use actionSubmit tag:

<g:actionSubmit value="My Button" action="myAction" />

In a general way, you can use createLink to generate links to actions:

<a href="${createLink(action:'myAction', controller:'myController')}">

Upvotes: 3

Related Questions