0

In my 'Spring Source Tools Suite', I imported a project that was built using command line Grails v1.3.7. The IDE uses v2.2.3. I have a good part of the application working, but two things don't work, and I have been hard at it for the better part of two days trying to get it working. The two parts that don't work are uploading jpeg files and capturing text on a button click. I am asking for help with the later problem only in this question. Here is the error message: Message: It looks like you are missing some calls to the r:layoutResources tag. After rendering your page the following have not been rendered: [defer]

These calls are to classes outside my project, and inside dependency classes. I have no idea what is calling them or how I would fix this.

Thanks in advance for help,

~Bill

PS: I know that it is considered bad form adding questions on to other people's questions that have already been answered. So instead I will add a link to another topic that I read here: Grails Resources Plugin and AJAX loaded javascript . However I don't have a g:layoutBody in my gsp template. Would I add r:layoutResources disposition="defer"/ after each g: ... anything or after the g.form tag. Any assistance is appreciated.

Community
  • 1
  • 1
Bill J
  • 55
  • 1
  • 8
  • Basically, what I am asking is: "Where do I place the calls to `r:layoutResources` in the code, and what determines if I need the addition of `disposition="defer"/` or not ? – Bill J Oct 24 '13 at 16:50

1 Answers1

0

Take a look at the documentation of the tag r:layoutResources: http://grails-plugins.github.io/grails-resources/ref/Tags/layoutResources.html

This tag has special behaviour, in that the first time it is called it renders the resources with disposition "head" (intended to be included within the section of your page) and the second time it is called it renders the disposition "defer" resources.

So there is no need to put disposition="defer" in the tag as it automatically renders the second tag as disposition "defer".

Furthermore the documentation also shows a best practice where to place these calls.

For best use, this should be called in the head and at the end of the body in your Sitemesh layout.

<html>
   <head>
      <g:layoutTitle/>
      <r:layoutResources/>
   </head>
   <body>
      <g:layoutBody/>
      <r:layoutResources/>
   </body>
</html>

So it would be best if you had a main layout where you placed these tag calls at the end of head and body. Using this layout in your views then ensures that r:layoutResources gets called correctly after all other calls to resource tags.

cawka
  • 437
  • 4
  • 13
  • Thank you cawka. I did this in the main.gsp that I had already and it worked. One thing I can't get is what the distinction is between a layout and a view, since they are all .gsp files. But perhaps more importantly, why do I need the r.layoutResources code now with Grails 2.2.3, when I didn't using v1.3.7 ? – Bill J Oct 28 '13 at 14:05
  • In newer versions of Grails the dependency for the resources plugin is included by default. You should have something like `runtime ":resources:1.2"` in your BuildConfig.groovy. If you don't want to use it just remove this line. – cawka Nov 09 '13 at 10:57
  • No there is nothing of the sort in the BuildConfig.groovy file. – Bill J Nov 11 '13 at 14:18