Jason
Jason

Reputation: 11363

Grails- Add link href to button

I'm building a simple Grails app for a web development class. For the most part, the app is finished, but I'm having one sticking issue.

On the index page, I have a series of buttons that correspond to the List, Create, and other templates that are built in Grails via scaffolding. How can I dynamically pass on the correct path to the controller action?

In order to do this, I need to get the current page URL and add the proper location. Is that possible to do in Grails or should I stick with jquery or some other ajax solution?

Upvotes: 1

Views: 5875

Answers (2)

Sudhir N
Sudhir N

Reputation: 4096

What are you trying to achieve here,

If you want to generate link to controller actions that you can use for button href, you can do it like this,

<button href="${createLink(controller:'foo', action:'bar')}"/> 

See the createLink tag

If you want to know controller and action name, ${controllerName} and ${actionName} can be used.

Upvotes: 8

tim_yates
tim_yates

Reputation: 171184

Can you use ${controllerName} to get the name of the current controller?

An alternative might be ${params.controller}, but again, not 100% sure it works in gsps

Upvotes: 0

Related Questions