1

In our application which is based on grails 2.0.4 we have overwritten the grails ApplicationTagLib. After the migration to grails 2.1.0 overwritting of the ApplicationTagLib is no longer working. In our gsp the returned result is just empty.

Here is the simplified TagLib which is used by us:

class CustomizedGrailsTagLib implements ApplicationContextAware {
  // grails native taglib classes
  def applicationTagLib

  void setApplicationContext(ApplicationContext applicationContext) {
    applicationTagLib = applicationContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib')
  }

  def createLink = { attrs ->
    // call native create link after modifications
    def link = applicationTagLib.createLink.call(attrs)
    return link
  }
}

When debugging we see that the variable link has the correct value (e.g. /enterprise20/user/showImage/7). But afterwards in the gsp the output is empty.

GSP call:

${createLink(controller:'user', action:'showUser', id: userInstance.id)}
4

1 回答 1

1

Rather than returning the value, try writing it to out:

def createLink = { attrs ->
  // call native create link after modifications
  def link = applicationTagLib.createLink.call(attrs)
  out << link
}
于 2012-08-02T16:43:45.047 回答