Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def save = {
- def id = params.id=="" ? 0 : params.id.toInteger()
- def p = (id>0) ? Page.findById(id) : new Page()
- p.properties = params
- def ps = PageSuite.findById(params.page_suite_id)
- ps.pages << p
- ps.save()
- def data = [success:true, data:[id:p.id, title:p.title, description:p.description, page_suite_id:ps.id]]
- render data as JSON
- }
- // p.id is NULL, how to get the id of the newly created Page ?
- class PageSuite {
- List pages
- static hasMany = [pages:Page]
- static constraints = {
- }
- static mapping = {
- sort 'title'
- }
- String title
- String description
- int sortorder
- }
- class Page {
- static constraints = {
- title()
- description()
- }
- static mapping = {
- sort sortorder:'asc'
- }
- static belongsTo = [pageSuite:PageSuite]
- static hasMany = [pageElements:PageElement]
- String title
- String description
- int sortorder
- }
Add Comment
Please, Sign In to add comment