Smarter Grails Tags
While the tags in grails provide a lot of useful features, there is room for improvement. This page outlines some ideas for improvements of the different tags. Feel free to expand this article to other tags.
Form Tags:
<g:textField).
Rendering Tags.
class NavigationCommand implements Serializable { Integer max = 20 Integer offset = 0 String sort = "" String order = "asc" }:
def list { NavigationCommand nav -> // Some code ... [ total : total, ..... ] }
I should be able to use the following tag:
<g:paginate.
Feb 22, 2008
Kristian Mandrup says:Yes, this approach has been take successfully by a lot of other frameworks and s...
Yes, this approach has been take successfully by a lot of other frameworks and seems to make sense somewhat.
On the other hand, use of the "class" is more like a Decoration, and the logic behind the Decorator decision can quickly become more complex. It would make more sense to allow externalization og this Decorator logic, making it independant of the UI and more flexible.
The bean-mapping is more tightly coupled to the form control so it makes perfect sense to have the binding expressed directly in the tag.
I imagine that the controls could be set to different states depending on the state of some underlying model. The states could then be mapped (Layout-mapping.config?) to certain CSS classes or some other annotation/decoration of the control.
Fx:
formGroup "interview" {
state "null" {
default "error"
form.input "error-star"
}
state "validated" {
default "ok"
form.input "ok-check"
}
}
formGroup "login" {
...
}
or something similar. Then I can opt to change the state-to-class mapping across a select set of forms (belonging to a named formGroup(s) on multiple pages acroos the site in a central location, declaratively.
Just an idea
Kristian M
Feb 22, 2008
Ryan Stuart says:Sounds like a good idea to me. It goes without saying this should only be on opt...
Sounds like a good idea to me. It goes without saying this should only be on option and not forced upon anyone. I think the default should be to just render the class error. But what you suggested in your comment Kristian would definitely make the new tag features a lot more powerful.
Jul 24, 2008
J says:Here a quick solution for the smarter Grails tag problem:...
Here a quick solution for the smarter Grails tag problem: