Created
May 2, 2012 03:15
-
-
Save uris77/2573327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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