InLink tag : To provide links to important words in the contents.

14 / Mar / 2011 by shweta 2 comments

Hi , this is a very simple but yet useful tag to provide links to important words in the content given in between the starting and end inLink tag.

Taking an Example of contents :-

“No One Killed Jessica is a 2011 Hindi film starring Vidya Balan and Rani Mukherjee , produced by UTV Spotboy and directed by Raj Kumar Gupta, who had earlier directed the acclaimed film Aamir (2008). Vidya Balan plays the character of Jessica’s elder sister, Sabrina Lal, Rani is set to play a reporter.[7] . The director clarified that the title and the script are actually inspired by a headline carried out by The Times of India (epaper link) in 2006, when the accused in the infamous murder case were acquitted by the lower courts.The film, No One Killed Jessica is based on the true story of Jessica Lal, a Delhi-based model, who was shot in 1999 at a New Delhi restaurant by Manish Bhardwaj, alias Manu, the son of an influential Haryana politician.In February 2006, the court acquitted.  It received positive reviews from critics.[12]No One Killed Jessica opened quite well and got positive feedback from audience.No One Killed Jessica received a number of positive reviews. Nikhat Kazmi of the Times of India gave the movie four stars out of five stating. ”

Output after passing the contents between inLink tag :

This tag takes celebrity list and movie list as input and then just replaces each  celebrity name or  movie name with its link which takes to the corresponding celebrity page or movie page.

Now the code for the inLink tag is as follows :-

def inLink = {attrs, body ->
List<Celebrity> celebrities = attrs[‘celebrities’]
List<Movie> movies = attrs[‘movies’]
String bodyText = body()
String currentCelebrity
String currentMovie
celebrities.each {currentSelect ->
currentCelebrity =
bodyText = bodyText.replaceAll(currentCelebrity, (hys.celebrityPageLink(id:,title:currentCelebrity ) {currentCelebrity}).toString())
movies.each {currentSelect ->
currentMovie =
bodyText = bodyText.replaceAll(currentMovie, (hys.moviePageLink(id:,title:currentMovie) {currentMovie}).toString())
out << bodyText

Here ,two more tags :- celebrityPageLink tag and moviePageLink tag are used which are defined under the namespace “hys” .These two tags are very similar ,one links its given content i.e. celebrity name to its corresponding celebrity page and the one links its given content i.e. movie name to its corresponding movie page. Lets see the code for one of these tags for sake of avoiding confusion regarding these.

Taking celebrityPageLink tag which takes celebrity id,title and class as input. Its code is as follows :-


def celebrityPageLink = {attrs, body ->

def celebrity =

out << ‘celebrity’, action: ‘show’, params: [name: celebrityName]) {body()}

Now lets see how to use this tag on gsp page :-

[html] <hys:inLink movies="${allMovies}" celebrities="${movie.getCelebrities()}">${movie.description}</hys:inLink> [/html]

ok……now lets see how much its useful for grails users.


Shweta Gupta



comments (2)

  1. Moriah Nepa

    Hello! I just wish to give you a big thumbs up for your excellent information you have got right here on this post. I will be returning to your web site for more soon.

  2. RaguPrashanth.R.V

    I having Two Different Domanis
    Eg:CoreFolder[ProductItem-Domain] & ProductionFolder[PatternShop].

    I pass these two domains params in Single list action in ProductItem Controller
    like: [ProductItem.list(),PatternShop.list()]

    Then I need to display Two domain params in single list page after vales are entered either any of one domain values.

    will u help me?


Leave a Reply

Your email address will not be published. Required fields are marked *