Questions tagged [command-objects]

Command Objects are a feature of the Grails web framework, refering to special classes that declare constraints used to validate its instances.

Resources

Official docs

Related tags:

90 questions
1
vote
1 answer

Groovy 2.4.4 command objects - reusing validator closure

Let's saying I have the following command: @Validateable class MyCommand { String cancel_url String redirect_url String success_url static constraints = { cancel_url nullable: false, validator: { url, obj -> …
Paul Erdos
  • 1,355
  • 2
  • 23
  • 47
1
vote
2 answers

Grails 1.3.5 controller test nulls command object

Straight from page 104 of "The Definitive Guide to Grails (Second Edition)": void testLoginUserNotFound() { mockRequest.method = "POST" mockDomain(User) MockUtils.prepareForConstraintsTests(LoginCommand) def cmd = new…
Alan Escreet
  • 3,499
  • 2
  • 22
  • 19
1
vote
0 answers

Grails/Angular $http() not binding Command Objects

We are currently working on upgrading our project from Grails 2.2 to Grails 3.0 and have run into numerous issues. The one I'm currently working on has to do with Angular $http() and Command Objects not data binding correctly. We currently let…
1
vote
0 answers

Grail : GSP Input parameter name in case of nested list in grails command object

I am using grails 2.5 , my command object is class TestCommand{ List aList; // Class A List } class A{ String name; List bList; // Class B List } class B{ String name; } In my GSP
1
vote
1 answer

Grails 2.5.0 - constraint be blank OR follow validation

I want to do something like: class MyCommand { String name String data static constraints = { name blank: false, size: 3..64 data (blank: true) || (blank: false, size: 3..64) } } where data is either blank or…
Anonymous1
  • 3,877
  • 3
  • 28
  • 42
1
vote
1 answer

How can I map values of an array into command objects using Grails?

normally I use command objects to work with submitted values. But if multiple values of the same property are submitted via AJAX (using jQuery) I was not able to use command objects. In my GUI the user can click on checkboxes to mark some objects.…
Daniel
  • 835
  • 1
  • 7
  • 18
1
vote
1 answer

Can one constraint on a command object check the result of another?

This is a simple example that doesn't work, I'm wondering if there is a way to validate a inside the validator block of b if it hasn't already been validated. Example how I thought it would work: static constraints = { a nullable: false b…
Lifeweaver
  • 986
  • 8
  • 29
1
vote
0 answers

Binding a Set of domain object in Grails command object

I'm trying to bind a Set of objects to my Grails Command Objects, but currently, it doesn't work an throws errors: Field error in object 'NewPersonCommand' on field 'addresses': rejected value [[Ljava.lang.String;@6d64b5fb]; codes…
Erik Pragt
  • 13,513
  • 11
  • 58
  • 64
1
vote
1 answer

Grails - Bind parameter to command object field of a different name

If I have a command object SomeClassCommand with a String field someField but want to bind data from a parameter params.otherField, how do I go about doing that? Is there an annotation I can put in the command object?
Anonymous1
  • 3,877
  • 3
  • 28
  • 42
1
vote
1 answer

Grails Plugin: Getting all command object classes

In a plugin, I need to iterate over all domain and command object classes to apply some meta-magic to them. Getting the domain classes isn't a problem, however command objects are not that easy to get hold of, since they don't seem to be considered…
Daniel Rinser
  • 8,855
  • 4
  • 41
  • 39
1
vote
0 answers

Command Object forgets to validate from time to time?

I am using Grails 1.3.7 and I have similar code in multiple controllers: def myAction = { MyCommand cmd -> if (cmd.hasErrors()) { // return bad request } else { someService.callSomeMethod(cmd.someId) ... …
medvaržtis
  • 128
  • 1
  • 11
1
vote
2 answers

Extended Grails command object constraints validation

Having the following commandobjects in Grails: class commandA implements commandObjectType { String a static constraints = { a blank: false } } and class commandB extends commandA { String b } How would one the implement…
Hoof
  • 1,738
  • 2
  • 17
  • 39
1
vote
0 answers

Grails WebFlow and Command Objects: Only One Command Object allowed?

Grails 1..3.7 In regular controller actions I can do the following: def someAction = { OneCommand oneCmd, TwoCommand twoCmd -> } However, in a webflow action I have the equivillent: def someFlow = { someAction { on("something") { OneCommand…
Gregg
  • 34,973
  • 19
  • 109
  • 214
0
votes
1 answer

Grails Command Object nullable constraint

I recently upgraded a 1.3.6 application to Grails2. My test cases have started failing Here is the scenario, I have a command object and a constraint. When the request hits the action, without the parameter name…
Karthick AK
  • 208
  • 2
  • 5
0
votes
2 answers

grails command object and fields with prefixes

Im using grails 1.3.7 and here is the case... Have a huge form with a few different prefixes for its fields (later used in data binding) and trying to validate thru a command object... however the lovely DOT used in prefixes is giving me a hard…
Sepi
  • 35
  • 7