Fork me on GitHub

21 May 2011

Resources plugin and modular web components for Grails apps

I recently gave a talk on ‘Building progressive UIs with Grails’ at gr8conf in Copenhagen and was really pleased with the feedback & comments I received afterwards. There was a question asked at the end that I felt in retrospect I could have answered better, though. I had mentioned that the Grails AJAX tags were something that should be avoided as they write script blocks directly into the page and event handlers directly onto HTML elements. I was pitching an approach based on a clean separation of clean semantic markup and script enhancements and inline script violates that separation.

I was asked if there might be any kind of tags that could be developed that provided a more appropriate replacement and answered that since modern JavaScript frameworks such as jQuery make decorating elements with AJAX functionality so easy that I didn’t think there was much point.

I wouldn’t want anyone to understand me to mean that creating taglibs and GSP templates for modular components of your pages is a bad thing. I’d just advocate keeping the script out of them. Custom tags that write out markup or delegate to templates can be really useful for building complex reusable modules. Pairing those with external JavaScript files that enhance the generated markup would be very effective.

If you’re using the resources plugin (and really… you should be) then there’s a really neat way to tie the taglib or template to the JavaScript file as well. I did briefly mention this in my talk but it’s worth expanding on here as it’s a technique with a lot of potential.

The resources plugin’s r:use tag doesn’t write out anything directly to the page but rather adds a resource module to a list that will get written out at the appropriate place in the page when the r:layoutResources tag is used. This means modular components throughout the page can declare a dependency on JavaScript and CSS resources by simply calling r:use. In a complex app this can be a real boon as it might not be obvious from the top level GSP exactly which modules are going to get rendered. Also if a module is later added to or removed from a page you don’t need to worry about fiddling around with resource declarations in the top level GSP. Taglibs or templates become real drop in components whilst maintaining a nice clean separation of markup and script. Even better, if you use the same resource dependency multiple times the plugin ensures the resources are actually only linked once.

Since r:layoutResources is typically used in a SiteMesh layout the resources your module depends on can even be ones that need to appear in the head of the document. The SiteMesh is rendered after the GSP it decorates so any r:use calls will already have been made.

36 comments:

Unknown said...

You blog post is just entirely quality and useful, many new facts and information which I have not heard about before.
essay writing service reviews

Unknown said...

You need to kill time, you need entertainment. Refer to our website. hope you get the most comfort.
Thanks you for sharing!
Friv 4

Unknown said...

Can I simply say what a comfort to discover someone who actually understands what they're discussing on the web. You certainly realize how to bring an issue to light and make it important. More and more people need to check this out and understand this side of your story. It's surprising you aren't more popular given that you surely have the gift. www.menstopspot.com | www.pureitfresh.com | www.warmmensfashion.com | www.urbanplussizeclothing.org | www.burgundybodycondress.com

ngocanh said...

Your blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including me.I actually appreciate your own position and I will be sure to come back here.
hotmail login l login hotmai l hotmail log in l hotmail sign in l hotmail sign up

Unknown said...

Looking for some addicting Korean TV shows to watch? ... For example, variety shows tend to use simple, conversational language, while dramas can cover a ...Feb 27, 2017 - Several hit South Korean variety shows have been removed from major streaming platforms in China over the past two days.Best Korean Variety Shows interactive top ten list at TheTopTens ®. Vote, add to, or comment on the Best Korean Variety Shows.Read FACT #9 || What Korean Variety shows & K- Dramas I've watched || from the story ~ All about Meh~ by PinkPrincessJinOppa (ʕ•ᴥ•ʔ Cutie ʕ•ᴥ•ʔ) with 43 ...Dailymotion United States - Playlist Korean Variety Shows.Find and follow posts tagged korean variety show on Tumblr.Translate Korean variety shows. See Spanish-English translations with audio pronunciations, examples, and word-by-word explanations.

我愛你 said...


What you do is beautiful and very sexy. Please take care and do not shorten what you do
العاب سباق 2018
العاب طبخ
العاب تلبيس

Unknown said...


شركة كشف تسربات المياة بالدمام

شركة مكافحة بق الفراش بالدمام
هل تود الاستعانة بأفضل شركات عزل الاسطح بالدمام مع الحصول علي اكبر فترة ضمان عليك بشركة النسور تقدم الشركة عروض وخصومات رائعة فقط عليك بزيارة موقعنا

شركة عزل اسطح بالدمام



شركة مكافحة حشرات بالخبر

Linda said...

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write
run2online.net

نور الهدى said...


شركة غسيل خزانات بالمدينة المنورة و عمال مروبون وحاصلون على شهادة صحية فقط اتصل بنا لتحصل على افضل خدمة غسيل خزانات


الصفوة جروب said...

مغسلة الجبر
مغاسل الجبر للتنظيف
مغاسل الجبر بالرياض
مغسلة الجبر للتنظيف

الصفوة جروب said...

شركة امست للتنظيف افضل شركة لتنظيف المنازل والشقق والفللوالبيوت والمجالس والكنب والمفروشات والخزانات بالقطيف والمنطقة الشرقية لديها عمالة مدربة وخصومات هائلة طما توفر خدمات مكافحة الحشرات ورش المبيدات بالقطيف باسعار رخيصة ومناسبة وخصومات هائلة

شركة امست للتنظيف
امست للنظافة القطيف
شركة امست لمكافحة الحشرات
شركة امست لرش المبيدات

الصفوة جروب said...

مغسلة الجبر
مغاسل الجبر للتنظيف
مغاسل الجبر بالرياض
مغسلة الجبر للتنظيف

الصفوة جروب said...

شركة تنظيف كنب بالقطيف
شركة تنظيف مكيفات بالقطيف
شركة تنظيف مطابخ بالقطيف
شركة مكافحة حشرات بالقطيف
شركة مكافحة النمل الابيض بالقطيف

الصفوة جروب said...

افضل شركة تنظيف بالقطيف تقدم خدمات نظافة متكاملة علي اعلي مستوي بدقة وجودة ومواصفات قياسية واسعار تنافسية فتعد الشركة الاولي بالقطيف لتقديم خدماتالتنظيف بجودة وسعر مثالييينفهي خير مثال لراغبي الحصول علي نظافة شاملة مع التعقيم وباسعار مناسبة

شركة تنظيف بالقطيف
شركة تنظيف منازل بالقطيف

______________________________________________________________________________________________________________________


شركة كشف تسربات المياه بالقطيف
شركة تنظيف مجالس بالقطيف
شركة تنظيف خزانات بالقطيف
شركة شفط بيارات بالقطيف

الصفوة جروب said...

هل تعانون من الحشرات وكثرتها واضرارها البالغة نقدم لكم افضل شركة لابادة جميع انواع الحشرات بالضمان وهي شركة المثالية لمكافحة الحشرات حيث تقدم اليوم افضل العروض والخدمات بارخص الاسعار بخصم 50% لفترة محدودة

شركة المثالية لمكافحة الحشرات
شركة المثالية لمكافحة الحشرات بالدمام
شركة المثالية لمكافحة الحشرات بالخبر
شركة المثالية لمكافحة الحشرات بالقطيف
______________________________________________________________________________________________________________
شركة المثالية لمكافحة الحشرات بالاحساء
شركة المثالية لمكافحة الحشرات بالجبيل
شركة المثالية لمكافحة الحشرات بجدة

الصفوة جروب said...

شركة المثالية للتنظيف افضل شركة تنظيف بالمنطقة الشرقية تخصصت في تقديم كافة الاعمال المنزية من نظافة ومكافحة حشرات بالمنطقة فلديها افضل الخدماتبافضل جودة واوبارخص الاسعار التي لا تتوفر الا معها كافضل وارخص شركة تنظيف بالاضافة الي خدمتا مكافحة الحشرات ورش المبيدات الامنة والفعالة علي الحشرات بجميع انواعها .. تقدم لكم اليوم افضل العروض والخدمات بخصومات هائلة يمكنكم الحصول عليها من خلال الروابط التالية

شركة المثالية للتنظيف
شركة المثالية للنظافة
شركة المثالية للتنظيف بالدمام
شركة المثالية للتنظيف بالخبر
شركة المثالية للتنظيف بالقطيف

الصفوة جروب said...

شركة ماسة لمكافحة الحشرات
شركة ماسة لرش المبيدات
شركة ماسة لمكافحة الحشرات بالاحساء
شركة ماسة لمكافحة الحشرات بالرياض

الصفوة جروب said...

شركة طيوب لتسليك المجاري
شركة طيوب لتسليك المجاري بالقطيف
شركة طيوب لتسليك المجاري بالدمام
شركة طيوب لتسليك المجاري بالخبر
شركة طيوب لتسليك المجاري بالاحساء

الصفوة جروب said...

شركة ورس لمكافحة الحشرات
شركة ورس لرش المبيدات
شركة ورس لمكافحة الحشرات بالاحساء

Unknown said...

Pakistani colleges deliver extremely difficult tests, at this time, medical meetings and tests. Difficult testing at different colleges is difficult. Additionally, there is an outlet plan. NTS is a Pakistan-based organization that manages school tests for companies in country and higher education Pakistan link. There are more colleges that go beyond the NAT test. The NTS has its own NAT team and their source to evaluate the travel of Pakistan Partner Colleges. Equipment, to NTS; will be discontinued from all NTS colleges. Many students now vote on the NAT NTS to be tested at the Colleges.


شركه تنظيف said...

كشف تسربات المياه بجدة
نقل اثاث بالدمام
شركة عزل بالدمام
كشف تسربات المياه بالمدينة المنورة
شركة تنظيف بالرياض
نقل عفش بالرياض رخيص
خدمات منزلية بالرياض

Unknown said...

Nice Blog, Thank you so much for sharing such an amazing blog.
sound engineering courses

nandhu said...


zapya for windows
zapya pc
zapya apk download
zapya free download
In the end, one friend sends around two snapshots and everyone else forgets about it.

Akira said...

Eng vs SA World Cup 2019
Wi Vs Pak wolrd Cup 2019
When Is fathers day 2019
Happy 4th Of July Images

Akira said...

Eng vs SA World Cup 2019
Wi Vs Pak wolrd Cup 2019
When Is fathers day 2019
Happy 4th Of July Images

jacklinemelda said...

Every student has the chance of enjoying our affordable research paper writing service. The writers hired at the company are professionals with significant experience.

harshak said...

https://www-tutuapp.com/
tutuapp
tutuapp download
tutuapp apk best ios helper
tutuapp vip
tutuapp apk
tutuapp ios

شركة رواد الحرمين said...


شركه تنظيف منازل بالدمام
أيضاً تسبب في سقوط الطلاء وظهور التشققات، ولكن من الآن لا داعي

Tech Solitic said...

TechSolitic Windows 7 issues.

Ivymelda said...

Acquiring academic Custom College Papers is easy and convenient for you in the Essay Writer Services and Admission Essay Writing Services company.

meldaresearch said...

Are you looking to buy the Best Custom Essay Paper from the best writers? When given assignments, many students look for Top-Ranked Essay Writing Service and through a basic web search, you can find many online companies offering help with Best Custom Essay Ever.

akshayavengala said...

mobdro
mobdro apk
mobdro app
mobdro download
mobdro for android
It is also among the best live streaming apps.

homa hakeem said...


شركة عزل اسطح بجازان
شركة مكافحة حشرات بجازان
شركة نقل اثاث بجازان
شركة كشف تسريات المياه بنجران
شركة تنظيف بخميس مشيط
شركة تنظيف منازل بخميس مشيط
شركة تنظيف خزانات بخميس مشيط
شركة كشف تسربات المياه بخميس مشيط
شركة مكافحة حشرات بخميس مشيط
شركة رش مبيدات بخميس مشيط

sandeepaleti36 said...


snapchat on dark themeThank for sharing this awesome post love to read this.

ROHIT RAJWANI said...

Putlocker may be a seamless portal for television, series, movies, songs, etc. for free. it's not mainly for any film or language, from Hollywood to Bollywood, one can have access to each possible movie. In fact, unlike other portals who operate completely illegally, Putlocker has an official site named Putlocker.com that a broad base of individuals is mad.

For the official content recorded, over 1.6 million people worldwide made access to it portal on a per-day basis. because of the piracy issues, it faced a report by motion picture Association of America, which led to its pack up by the united kingdom court Order. it had been considered together of the highest 250 sites visited by the people worldwide. Although, thanks to its massive fan base, Putlockers remains operated under different proxy websites.


In October 2018, the MPAA's report on Online Notorious Markets to the United States Trade Representative, said that the conclusion of 123movies, 123movieshub, gostream, and gomovies, by walking of a criminal examination in Vietnam in 2018, was "a significant turn of events" in combatting illicit film theft administrations. In any case, the MPAA report additionally noticed that various copycat locales had risen in any event eight different nations. In November 2018 TorrentFreak revealed locales associated or like 123Movies, for example, WatchAsap had additionally been closed somewhere around the FBI, yet were re-coordinating to other document sharing destinations.

عبد الله محمد عبدالله said...


شركة تنظيف مكيفات بالرياض
شركة تنظيف شقق بالرياض
شركة تنظيف موكيت بالرياض
شركة تنظيف واجهات زجاج بالرياض