Skip to content

Instantly share code, notes, and snippets.

@uris77
Created May 2, 2012 03:15
Show Gist options
  • Save uris77/2573327 to your computer and use it in GitHub Desktop.
Save uris77/2573327 to your computer and use it in GitHub Desktop.
package com.example
import org.zkoss.zk.grails.*
class PersonFacade {
def all(){
def persons = []
for(_person in Person.list()){
def person = [
id: _person.id,
firstName: _person.firstName,
lastName: _person.lastName,
website: _person.website,
email: _person.email
]
persons.add(person)
}
return persons
}
def create(params){
def _person = [:]
Person person = new Person()
person.properties['firstName','lastName','email','website'] = params
person.validate()
if(person.hasErrors()){
_person.errors = person.retrieveErrors()
}else{
person.save()
_person = person.properties['id','firstName','lastname','email','website']
}
return _person
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment