Created
October 3, 2011 07:57
-
-
Save chanwit/1258658 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
| <window apply="PersonComposer"> | |
| <grid> | |
| <rows> | |
| <row> <textbox id="txtFirstName"/> </row> | |
| <row> <textbox id="txtLastName"/> </row> | |
| <row> <textbox id="txtFullName"/> </row> | |
| <row> | |
| <hbox id="boxDialog"> | |
| <button>Save</button> | |
| <button>Cancel</button> | |
| </hbox> | |
| </row> | |
| </rows> | |
| </grid> | |
| </window> | |
| class PersonComposer { | |
| def viewModel // MyViewModel | |
| // handler | |
| def onClick_btnSave(e) { | |
| def person = viewModel.person | |
| Person.withTransaction { | |
| person.save() | |
| } | |
| } | |
| } | |
| /* | |
| page-scoped | |
| */ | |
| class PersonViewModel { | |
| def binder | |
| List<Person> personList | |
| Person person | |
| static binding = { | |
| txtFirstName value:"firstName" | |
| txtLastName value:"lastName" | |
| txtFullName value: fullname | |
| boxDialog.$("> button") { | |
| disabled = disable | |
| } | |
| txtDayRemain style: dayRemain | |
| } | |
| def fullname = [ | |
| forward: { "${person.firstName} ${person.lastName}" }, | |
| reverse: { fullname -> (person.firstName, person.lastName) = fullname.split(' ') } | |
| ] | |
| def dayRemain = { | |
| if (person.dayRemains < 10) | |
| "red" | |
| else | |
| "black" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment