source: trunk/src/grails-app/controllers/PersonGroupController.groovy @ 40

Last change on this file since 40 was 40, checked in by gav, 16 years ago

Added login page and adjusted Person domain/views/controller and BootStrap?.
Add beforeInterceptor() to all controllers.
Added BaseController?.
Added adminmenubar adjust layout and css to suite.

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