Ignore:
Timestamp:
Jan 19, 2009, 8:31:46 PM (15 years ago)
Author:
gavin
Message:

Remove TypeOfClass? and change to ClassType?. Update ERD to match.
Create and add openMimLogo/Icon.
Generate-all *.
Configure BootStrap? and add entries, some not saving yet.
Update DatabaseDesign?.tex and index.gsp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/grails-app/controllers/EntryController.groovy

    r16 r21  
    11class EntryController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = Entry
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ entryInstanceList: Entry.list( params ) ]
     11    }
     12
     13    def show = {
     14        def entryInstance = Entry.get( params.id )
     15
     16        if(!entryInstance) {
     17            flash.message = "Entry not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ entryInstance : entryInstance ] }
     21    }
     22
     23    def delete = {
     24        def entryInstance = Entry.get( params.id )
     25        if(entryInstance) {
     26            entryInstance.delete()
     27            flash.message = "Entry ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "Entry not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def entryInstance = Entry.get( params.id )
     38
     39        if(!entryInstance) {
     40            flash.message = "Entry not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ entryInstance : entryInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def entryInstance = Entry.get( params.id )
     50        if(entryInstance) {
     51            entryInstance.properties = params
     52            if(!entryInstance.hasErrors() && entryInstance.save()) {
     53                flash.message = "Entry ${params.id} updated"
     54                redirect(action:show,id:entryInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[entryInstance:entryInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "Entry not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def entryInstance = new Entry()
     68        entryInstance.properties = params
     69        return ['entryInstance':entryInstance]
     70    }
     71
     72    def save = {
     73        def entryInstance = new Entry(params)
     74        if(!entryInstance.hasErrors() && entryInstance.save()) {
     75            flash.message = "Entry ${entryInstance.id} created"
     76            redirect(action:show,id:entryInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[entryInstance:entryInstance])
     80        }
     81    }
    482}
Note: See TracChangeset for help on using the changeset viewer.