small medium large xlarge

Back to: All Forums  Grails
Dklein_tiny_pragsmall
10 Sep 2009, 19:14
Dave Klein (34 posts)

There’s a new post on the Grails: A Quick-Start Guide blog (http://gquick.blogspot.com) where we write a unit test for one of the custom tags in TekDays.

If there’s some aspect of the book you’d like to see explored more deeply, let me know and maybe we can cover it there.

Thanks, Dave

Johannes-hartmann_pragsmall
11 Sep 2009, 08:14
Johannes Deutschland (18 posts)

A more depth in the chapter “Getting Things Done” would be nice.

Generic-user-small
11 Dec 2009, 08:31
Jerome Jahnke (3 posts)

Dunno if it is a explore more deeply request as much as it is if you used the MarkupBuilder in your Taglib examples it would make your code less error prone. The MarkupBuilder is one of those areas that Groovy really excels at, it would make your code easier to read (a small bit of exposition would explain to people what is going on) and make it less error prone for people working through it. To be honest I keep losing when I am supposed to be closing tags.

def volunteerButton = {attrs -> 
     if (session.user){
          def user = session.user.merge() 
          def event = TekEvent.get(attrs.eventId) 
          if (event && !event.volunteers.contains(user)){ 
               out << "<span id='volunteerSpan' class='menuButton'>" 
               out << "<button id='volunteerButton' type='button'>" 
               out << "Volunteer For This Event" 
               out << "</button>" 
               out << "</span>"
          }
     }
}

vs

def volunteerButton = { attrs ->
     if( session.user ) {
          def user = session.user.merge()
          def event = TekEvent.get(attrs.eventId)
          if (event && !event.volunteers.contains(user)){
               def writer = new StringWriter()
               def builder = new MarkupBuilder(writer)
               builder.span( id:'volunteerSpan', class:'menuButton'){
                    button( id:'volunteerButton', type:'button', 'Volunteer For This Event')
               }
               out << writer.toString()
          }
     }
}
Dklein_tiny_pragsmall
16 Dec 2009, 15:38
Dave Klein (34 posts)

Thanks Jerome,

That’s a great idea. I didn’t use MarkupBuilder because I would have had to explain it also and I was running into size/scope issues. But it would make a great blog post. Watch for it soon.

Dave

You must be logged in to comment