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
0
votes
1 answer

Grails Unit Testing a method with command object

I have a problem with my Unit Test. This is my Unit Test: void "Test the update action performs an update on a valid domain instance"() { given: def aclServiceMock = mockFor(AclService) aclServiceMock.demand.updateRolePermissions…
Francis
  • 1
  • 4
0
votes
1 answer

Need advice how to use service when creating an object of different type from another type of object in GRAILS

This example is about having a request from a customer where the seller can choose to make an offer to the customer. The request is stored in a class named 'Request' and the offer is stored in the class 'Offer'. The flow is: The seller picks up a…
larand
  • 773
  • 1
  • 9
  • 26
0
votes
3 answers

Grails - Command object, service method

I'm not a programming savvy person, so please bear with me. I've read blog entries and docs about command object. I've never used it and was wondering if I should. (I probably should...) My project requires parsing, sorting, calculating, and saving…
monty_bean
  • 494
  • 5
  • 25
0
votes
1 answer

Grails: Can you use create/save with Command Objects?

In all the examples I've reviewed of Grails command objects, the authors use new action names in their controllers (eg, "login", "register") rather than "create" or "save." Does the use of command objects for processing form data preclude the use of…
ScottyDont
  • 1,207
  • 1
  • 9
  • 17
0
votes
2 answers

Command object only in controller or could it be passed to service layer?

In Grails framework I saw the command object pattern but its use is not very clear for me. In addition most of examples given by Grails documentation are about domain classes not command objects (maybe to simplify code example). 1 - Command object…
Nico
  • 3,430
  • 4
  • 20
  • 27
0
votes
1 answer

Grails 2.5.0 - Command Object handle POST request with JSON

I have a form set up to send a POST request to a Grails controller, which is using a Command Object as its one parameter. The Command Object contains some properties binding correctly along with a List of items, which is not binding correctly. What…
Anonymous1
  • 3,877
  • 3
  • 28
  • 42
0
votes
3 answers

Grails best practice on form redirection/rendering

If I have an action def formPage(), I want to be able to save the form on that page, show the form with the previously entered values if there's an error, and show a blank form if it's a success. My question is: Is it best practice for formPage to…
Anonymous1
  • 3,877
  • 3
  • 28
  • 42
0
votes
1 answer

asp command object execute error on parameters including encoding

I am running a query using a command object but getting an unexpected error executing a query I need some help with. The same code appears to work just a few lines above and seems to have only appeared after I replaced the original db table to a…
Jason
  • 29
  • 2
  • 8
0
votes
1 answer

Grails: Command objects, view patterns and conditional form fields?

I'm trying to get the usage of Command Objects right. And I've got some questions. Given a generic domain, for instance: package com.foo class Ticket { Customer customer Product product Defect defect Solution solution String comment …
0
votes
0 answers

What is the expected way of handling abstract domain classes as command objects or command object properties in Grails?

Grails supports domain classes as properties of command objects out of the box. I can use a domain class Stuff with a command StuffCommand, but not if Stuff is an abstract class. Stuff.groovy abstract class Stuff{ } StuffCommand.groovy class…
nst1nctz
  • 333
  • 3
  • 23
0
votes
1 answer

Spring MVC 2.5 Command object value is changed on form submit

I have a string variable in command object which is a hidden tag in my jsp. An on click of a button i'm setting this variable with a value(example "test") and submitting the form. On form submit, I get the control to my Validator.validate()…
0
votes
1 answer

Grails command object and 404 when space inside JSON from CURL

I have inherited a controller. When a post request is made, with a well structured JSON document everything is fine. When the JSON contains a space in a feld, 404 is returned. However, when the same request is made from mozilla restclient extension…
Menelaos
  • 23,508
  • 18
  • 90
  • 155
0
votes
1 answer

Grails command objects validating fields based on the value of other fields

I have a command object @Validateable class PropertyDetailsCommand implements Serializable { Boolean ownerOccupied String personalDescription static constraints = { personalDescription validator:{value, obj, errs-> …
Sajeev Zacharias
  • 157
  • 1
  • 17
0
votes
1 answer

Instantiating abstract class multiple times with one action

So I have a, let's say, Pet abstract class, and three concrete implementations of it -- let's say Cat, Dog, and Bird. As concrete classes do, these guys share common fields and also have unique fields -- e.g., they all have Legs, but Birds alone…
0
votes
1 answer

Grails CommandObject validating when it should fail

I have the following Command Object in my Grails 2.2.3 application. @Validateable class PictureCommand { MultipartFile picture String notes Boolean isDocument static constraints = { picture nullable: false, validator: { val…
grantmcconnaughey
  • 10,130
  • 10
  • 37
  • 66