Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:27:04+00:00 2026-06-15T05:27:04+00:00

I made a script that loads content based on the current request locale. Something

  • 0

I made a script that loads content based on the current request locale. Something like

class ScriptsTagLib {
  static namespace = "my"
  def loadLangInfo = { attrs ->
    Locale locale = RequestContextUtils.getLocale(request)
    r.script() {
      out << '$(function(){ loadLangInfo("'+locale.language+'") });'
    }
  }
}

If I add this in my layout, the page throws an error:

Error evaluating expression [my.loadLangInfo()] on line [6]: Cannot
add module [-page-fragments-] which requires disposition [defer] to
this request – that disposition has already been rendered.

Error 2012-11-19 15:13:54,801 [http-bio-8080-exec-5] ERROR
[Tomcat].[localhost] – Exception Processing ErrorPage[errorCode=500,
location=/grails-errorhandler] Message:
java.io.UnsupportedEncodingException: The character encoding [null] is
not supported

But if I add this tag in my page instead of the layout, the page is rendered with success.

It’s not possible to add r.script() to a layout?

EDIT: The problem is really with resources in the layout. Another example that fails is:

<g:layoutHead/>
<r:script>
$(function(){ });
</r:script>
<r:layoutResources />

EDIT 2: More info about the context

  • Grails 2.0.4
  • Resources 1.2.RC2

Also, it’s a layout inside a plugin, and not one app.

Not tested in Grails 2.1, but will do that.

EDIT 3:

Just tested now, with Grails 2.1.1 and Grails 2.0.4 new fresh plugin projects, and the script tag in the layout is ignored!

./views/layout/test.gsp -> Script ignored

<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><g:layoutTitle default="Insoft4 UI Plugin"/></title>
        <g:layoutHead/>

        <r:layoutResources />
    </head>
    <body>
        <g:layoutBody/>
        <r:script disposition="defer">
            alert('layout!');
        </r:script>
        <r:layoutResources />
    </body>
</html>

./views/index.gsp -> Script OK

<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Teste</title>
        <meta name="layout" content="teste" />
                <r:script disposition="defer">
            alert('index!');
        </r:script>
        <r:layoutResources />
    </head>
    <body>
        <h1>Testing this index!</h1>
        <r:layoutResources />
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:27:05+00:00Added an answer on June 15, 2026 at 5:27 am

    I found out that the problem occurs when you have declared <r:layoutResources /> in both, layout and page and you try to add a script in the layout.

    To correct I removed the layoutResources from every view, leaving just in the layout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i made a script that dynamically loads content into a div and whenever the
I made a script that crawls through a domain, and I want it to
I made a script that spawns a remote shell or runs a local shell
I have made a script that uses a program called Diascope, its a video
What happes when the script that made @mysql_connect($server, $user, $password) dies? How long does
I made a little PHP script that checks if an email is valid. The
I've made a php script, that has the job to print text on a
I'm doing some animation script in RPG Maker XP (made with ruby) that allow
I have made an actionscript that loads an external text file, and scrolls its
Ok, basicly, I made a script (that one) that makes a .post to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.