{"id":23,"date":"2008-09-16T10:47:29","date_gmt":"2008-09-16T05:17:29","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=23"},"modified":"2015-07-10T17:54:02","modified_gmt":"2015-07-10T12:24:02","slug":"how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/","title":{"rendered":"How to invoke a GSP tag as a method in Grails GSP"},"content":{"rendered":"<p><a title=\"Grails Outsourcing\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">Grails has a lot of gems<\/a>. One of my favorites (besides GORM) is GSP tags &#8212; Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs.<\/p>\n<p>One of the features about GSP tags that I discovered and used today is that it is possible to invoke a GSP tag as a method call and assign the output of the tag to a variable.<\/p>\n<p>Lets jump to the example:<\/p>\n<p><span style=\"color: #003366;\">&lt;g:def var=&#8221;currentDomain&#8221; value=&#8221;${siteConfig.property(name:&#8217;regDomain&#8217;)}&#8221; \/&gt;<\/span><\/p>\n<p>In the above example:<\/p>\n<p><span style=\"color: #003366;\">siteConfig<\/span> : is the namespace of my taglib.<\/p>\n<p><span style=\"color: #003366;\">property<\/span> : is the name of the tag<\/p>\n<p><span style=\"color: #003366;\">name<\/span> : is the name of the attribute that I am passing to my tab<\/p>\n<p><span style=\"color: #003366;\">regDomain<\/span> : is the value of the &#8216;name&#8217; attribute.<\/p>\n<p>The output from the tag is stored in <span style=\"color: #003366;\">currentDomain<\/span> variable.<\/p>\n<p>Not sure if something similar is possible with plain JSP tags.<\/p>\n<p>-Deepak<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags &#8212; Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":6,"footnotes":""},"categories":[7],"tags":[4840,9,32],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-grails","tag-grails","tag-groovy","tag-gsp"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Deepak\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"article:tag\" content=\"grails\" \/>\n\t\t<meta property=\"article:tag\" content=\"groovy\" \/>\n\t\t<meta property=\"article:tag\" content=\"gsp\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2008-09-16T05:17:29+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2015-07-10T12:24:02+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#article\",\"name\":\"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog\",\"headline\":\"How to invoke a GSP tag as a method in Grails GSP\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2008-09-16T10:47:29+05:30\",\"dateModified\":\"2015-07-10T17:54:02+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#webpage\"},\"articleSection\":\"Grails, Grails, Groovy, gsp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#listItem\",\"name\":\"How to invoke a GSP tag as a method in Grails GSP\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#listItem\",\"position\":3,\"name\":\"How to invoke a GSP tag as a method in Grails GSP\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Deepak\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0707e9f5d93472c1d7bc0afaf21c81e0d6df62135f7e1426eb9e78bdd944f149?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Deepak\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/\",\"name\":\"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog\",\"description\":\"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\\\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2008-09-16T10:47:29+05:30\",\"dateModified\":\"2015-07-10T17:54:02+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog","description":"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to","canonical_url":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#article","name":"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog","headline":"How to invoke a GSP tag as a method in Grails GSP","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2008-09-16T10:47:29+05:30","dateModified":"2015-07-10T17:54:02+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#webpage"},"articleSection":"Grails, Grails, Groovy, gsp"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/www.tothenew.com\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#listItem","name":"How to invoke a GSP tag as a method in Grails GSP"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#listItem","position":3,"name":"How to invoke a GSP tag as a method in Grails GSP","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/admin\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/admin\/","name":"Deepak","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0707e9f5d93472c1d7bc0afaf21c81e0d6df62135f7e1426eb9e78bdd944f149?s=96&d=mm&r=g","width":96,"height":96,"caption":"Deepak"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/","name":"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog","description":"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/admin\/#author"},"datePublished":"2008-09-16T10:47:29+05:30","dateModified":"2015-07-10T17:54:02+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"article","og:title":"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog","og:description":"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to","og:url":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","article:tag":{"0":"grails","2":"groovy","3":"gsp"},"article:published_time":"2008-09-16T05:17:29+00:00","article:modified_time":"2015-07-10T12:24:02+00:00","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"How to invoke a GSP tag as a method in Grails GSP | TO THE NEW Blog","twitter:description":"Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java\/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"23","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"article","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 08:17:00","updated":"2024-02-29 11:01:21","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to invoke a GSP tag as a method in Grails GSP\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Grails","link":"https:\/\/www.tothenew.com\/blog\/category\/grails\/"},{"label":"How to invoke a GSP tag as a method in Grails GSP","link":"https:\/\/www.tothenew.com\/blog\/how-to-invoke-a-gsp-tag-as-a-method-in-grails-gsp\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}