Home How to Render a Grails View Without a Layout
Reply: 3

How to Render a Grails View Without a Layout

Travis Smith
Travis Smith Published in 2017-11-30 20:24:17Z

If you have a controller action, but don't want the view to be rendered with the default layout (in my case layout/main.gsp), is there a render option you can enter into the controller action or something similar?

def comingSoon {
  static layout = none;  //not correct, but something like this?
Joshua Moore
Joshua Moore Reply to 2017-11-30 20:42:24Z

Without more details it's difficult to say 100% what case you are in so I'll attempt to answer both.

If you are using dynamically scaffolded views then you'll need to generate the GSPs so you can remove the <meta name="layout" tag from them. This will keep any layout from being used.

Alternatively you could alter the scaffolding templates (within the scaffolding plugin) to include some additional logic about not applying a layout when the domain class has some static property (as your question contains).

elixir Reply to 2017-11-30 20:51:46Z

In your view file, you might see something like this

    <meta name="layout" content="main"/>  // delete this line
    <title>Coming Soon</title>

Remove the meta tag with the name="layout". This meta tag is the one that tells sitemesh to use the main layout

Syed Sarek
Syed Sarek Reply to 2017-12-03 06:43:02Z

You can remove <meta name="layout" content="main"/> to vanish exists layout. Or you may customize layout by edit that main.gsp page in your-project\grails-app\views\layouts\

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO