Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Contoller
- class DemoUrlMappingController {
- def action1(DemoUrlMappingCommand com) {...}
- def action2(DemoUrlMappingCommand com) {...}
- }
- //Command Object
- import grails.validation.Validateable
- @Validateable
- class DemoUrlMappingCommand {
- String userName
- String emailId
- String someOtherParameter
- //Mapped to default 'action' keyword in params
- String action
- static constraints = {
- userName validator: {val, obj ->
- if (obj.action == "action1"){
- //validate according to action1
- } else if (obj.action == "action2"){
- //validate according to action2
- }
- }
- emailId validator: {val, obj ->
- if (obj.action == "action1"){
- //validate according to action1
- } else if (obj.action == "action2"){
- //validate according to action2
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement