Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created September 10, 2009 03:41
Show Gist options
  • Save kellyrob99/184273 to your computer and use it in GitHub Desktop.
Save kellyrob99/184273 to your computer and use it in GitHub Desktop.
import groovy.xml.StreamingMarkupBuilder
def inputs = ['FirstName', 'LastName', 'Street', 'City', 'Country']
def controller = 'formController'
def bean = 'formBean'
def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
def doc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(ui: "http://java.sun.com/jsf/facelets",
h: "http://java.sun.com/jsf/html")
'ui:composition'(template: '/layout/main.xhtml') {
'h:form'(id: "${controller}_form") {
inputs.each {input ->
def inputId = input.toLowerCase().replaceAll(' ', '')
'h:outputLabel'(input, id: inputId, styleClass: 'inputlabel')
'h:inputText'(id: "${inputId}_input", value: "${bean}_$inputId", styleClass: 'inputText')
}
}
'h:commandButton'(id: "${controller}_submit", action: "#{${controller}.submit}", styleClass: "submitButton",
value: 'Submit')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment