Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created August 27, 2010 20:20
Show Gist options
  • Save aalmiray/554123 to your computer and use it in GitHub Desktop.
Save aalmiray/554123 to your computer and use it in GitHub Desktop.
import griffon.presentation.Scaffold
class Book {
String title
String author
}
@Scaffold(Book)
class BookBeanModel {}
// @Scaffold AST xform generates
//class BookBeanModel extends AbstractBeanModel {
// final Model title
// final Model author
//
// BookBeanModel() {
// super(Book)
// title = ModelUtils.makeModelFor(Book, this, 'title')
// author = ModelUtils.makeModelFor(Book, this, 'author')
// }
//
// List<Model<?>> getModelAttributes() {
// Arrays.asList(title, author)
// }
// }
// Model classes are fully observable
Model model = new BookBeanModel()
assert !model.value
assert !model.title.value
assert !model.author.value
Book book = new Book(title: 'Title1', author: 'Author1')
model.value = book
assert model.title.value == book.title
assert model.author.value == book.author
model.title.value = 'Title Changed'
assert book.title == 'Title Changed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment