RequestmapController.groovy
上传用户:steveyhw
上传日期:2019-05-13
资源大小:307k
文件大小:3k
源码类别:
PlugIns编程
开发平台:
Java
- /**
- * RequestController.groovy
- * Actions over Requestmap objects.
- * @author generated by plugin script
- * @auther Haotian Sun
- */
- class RequestmapController {
- def index = { redirect(action:list,params:params) }
- // the delete, save and update actions only
- // accept POST requests
- def allowedMethods = [delete:'POST',
- save:'POST',
- update:'POST']
- def list = {
- if(!params.max)params.max = 10
- [ requestmapList: Requestmap.list( params ) ]
- }
- def show = {
- [ requestmap : Requestmap.get( params.id ) ]
- }
- def delete = {
- def requestmap = Requestmap.get( params.id )
- if(requestmap) {
- requestmap.delete()
- flash.message = "Requestmap ${params.id} deleted."
- redirect(action:list)
- }
- else {
- flash.message = "Requestmap not found with id ${params.id}"
- redirect(action:list)
- }
- }
- def edit = {
- def requestmap = Requestmap.get( params.id )
- if(!requestmap) {
- flash.message = "Requestmap not found with id ${params.id}"
- redirect(action:list)
- }
- else {
- return [ requestmap : requestmap ]
- }
- }
- /*update action, called when an existing Requestmap is updated*/
- def update = {
- def requestmap = Requestmap.get( params.id )
- if(requestmap) {
- requestmap.properties = params
- //get user's enter field "configAttribute" from the params.
- String[] configAttrs=
- org.springframework.util.StringUtils.
- commaDelimitedListToStringArray(params.configAttribute)
- //Format the configAttributes to meet Acegi's requirement.
- String formattedConfigAttrs=""
- for(int i=0; i< configAttrs.length; i++){
- String configAttribute = configAttrs[i]
- println configAttribute+"---------"
- formattedConfigAttrs+="ROLE_"+configAttribute.toUpperCase()+","
- }
- requestmap.configAttribute=formattedConfigAttrs
- if(requestmap.save()) {
- redirect(action:show,id:requestmap.id)
- }
- else {
- render(view:'edit',model:[requestmap:requestmap])
- }
- }
- else {
- flash.message = "Requestmap not found with id ${params.id}"
- redirect(action:edit,id:params.id)
- }
- }
- def create = {
- def requestmap = new Requestmap()
- requestmap.properties = params
- return ['requestmap':requestmap]
- }
- /*Save action, called when a new Requestmap is created*/
- def save = {
- def requestmap = new Requestmap()
- requestmap.properties = params
- //get user's enter field "configAttribute" from the params.
- String[] configAttrs=
- org.springframework.util.StringUtils.
- commaDelimitedListToStringArray(params.configAttribute)
- //Format the configAttributes to meet Acegi's requirement.
- String formattedConfigAttrs=""
- for(int i=0; i< configAttrs.length; i++){
- String configAttribute = configAttrs[i]
- println configAttribute+"---------"
- formattedConfigAttrs+="ROLE_"+configAttribute.toUpperCase()+","
- }
- requestmap.configAttribute=formattedConfigAttrs
- if(requestmap.save()) {
- redirect(action:show,id:requestmap.id)
- }
- else {
- render(view:'create',model:[requestmap:requestmap])
- }
- }
- }