Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 2.0-RC1
-
Fix Version/s: 2.0-RC2
-
Component/s: View technologies
-
Labels:None
-
Environment:2.3GHz quad core processor with 4GB of memory running Win 7 x64. The environment is Java JDK version 1.7.0 with JAVA_OPTS set to -XX:MaxPermSize=256M -Xmx768M. GRAILS_HOME is set to version 2.0.0.RC1.
Description
Create an app with a domain of:
class Book {
String title
String state
static constraints = {
title(blank: false, size: 1..40)
state(inList: ['active', 'loginDisabled', 'actionsDisabled'])
}
}
Create the controller and views
Create a command object in src/groovy as follows:
class Operation {
String state
static constraints = {
state(inList: ['active', 'loginDisabled', 'actionsDisabled'])
}
}
Add an action to the Book controller as follows:
def operation(Operation operationInstance) {
operationInstance.state = 'active' // Any valid value will do
return [operationInstance: operationInstance]
}
create an 'operation' gsp that includes a form and within the form add the following input field:
<g:select id="state" name="state" from="${operationInstance.constraints.state.inList}" value="${operationInstance.state}"/>
Run the application and insert a new Book. The select list for the book's state is correctly populated. Now browse to the book/operation page. You will get an error that boils down to:
Caused by MissingPropertyException: No such property: state for class: test.Operation
where 'test' just happened to be the name of my app and thus the default package name also.
Activity
Burt Beckwith
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
Create an app with a domain of:
class Book { String title String state static constraints = { title(blank: false, size: 1..40) state(inList: ['active', 'loginDisabled', 'actionsDisabled']) } } Create the controller and views Create a command object in src/groovy as follows: public class Operation { String state static constraints = { state(inList: ['active', 'loginDisabled', 'actionsDisabled']) } } Add an action to the Book controller as follows: def operation(Operation operationInstance) { operationInstance.state = 'active' // Any valid value will do return [operationInstance: operationInstance] } create an 'operation' gsp that includes a form and within the form add the following input field: <g:select id="state" name="state" from="${operationInstance.constraints.state.inList}" value="${operationInstance.state}"/> Run the application and insert a new Book. The select list for the book's state is correctly populated. Now browse to the book/operation page. You will get an error that boils down to: Caused by MissingPropertyException: No such property: state for class: test.Operation where 'test' just happened to be the name of my app and thus the default package name also. |
Create an app with a domain of:
{code} class Book { String title String state static constraints = { title(blank: false, size: 1..40) state(inList: ['active', 'loginDisabled', 'actionsDisabled']) } } {code} Create the controller and views Create a command object in src/groovy as follows: {code} class Operation { String state static constraints = { state(inList: ['active', 'loginDisabled', 'actionsDisabled']) } } {code} Add an action to the Book controller as follows: {code} def operation(Operation operationInstance) { operationInstance.state = 'active' // Any valid value will do return [operationInstance: operationInstance] } {code} create an 'operation' gsp that includes a form and within the form add the following input field: {code} <g:select id="state" name="state" from="${operationInstance.constraints.state.inList}" value="${operationInstance.state}"/> {code} Run the application and insert a new Book. The select list for the book's state is correctly populated. Now browse to the book/operation page. You will get an error that boils down to: {code} Caused by MissingPropertyException: No such property: state for class: test.Operation {code} where 'test' just happened to be the name of my app and thus the default package name also. |
Burt Beckwith
made changes -
| Status | Open [ 1 ] | Closed [ 6 ] |
| Resolution | Not A Bug [ 6 ] |
Burt Beckwith
made changes -
| Resolution | Not A Bug [ 6 ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
Graeme Rocher
made changes -
| Fix Version/s | 2.0-RC2 [ 13004 ] | |
| Priority | Major [ 3 ] | Critical [ 2 ] |
Jeff Brown
made changes -
| Assignee | Jeff Brown [ brownj ] |
Jeff Brown
made changes -
| Status | Reopened [ 4 ] | In Progress [ 3 ] |
Jeff Brown
made changes -
| Priority | Critical [ 2 ] | Blocker [ 1 ] |
| Repository | Branch | Revision | Date | Author/Committer | Message |
| Grails Functional Tests | 2.0.x | aff877f... | 2011-11-07 12:55:10 -0800 | Jeff Brown / Jeff Brown | |
| Files Changed | |||||
|
MODIFY
apps/kitchen_sink_app/grails-app/controllers/commandobjects/CommandObjectsTestController.groovy
MODIFY apps/kitchen_sink_app/test/functional/commandobjects/CommandObjectsFunctionalTests.groovy |
| Repository | Branch | Revision | Date | Author/Committer | Message |
| Grails Functional Tests | master | a0f1e00... | 2011-11-07 13:59:27 -0800 | Jeff Brown / Jeff Brown | |
| Files Changed | |||||
|
MODIFY
apps/kitchen_sink_app/grails-app/controllers/commandobjects/CommandObjectsTestController.groovy
MODIFY apps/kitchen_sink_app/test/functional/commandobjects/CommandObjectsFunctionalTests.groovy |
| Repository | Branch | Revision | Date | Author/Committer | Message |
| Grails Functional Tests | 2.1.x | a0f1e00... | 2011-11-07 13:59:27 -0800 | Jeff Brown / Jeff Brown | |
| Files Changed | |||||
|
MODIFY
apps/kitchen_sink_app/grails-app/controllers/commandobjects/CommandObjectsTestController.groovy
MODIFY apps/kitchen_sink_app/test/functional/commandobjects/CommandObjectsFunctionalTests.groovy |
| Repository | Branch | Revision | Date | Author/Committer | Message |
| Grails Functional Tests | 2.2.x | a0f1e00... | 2011-11-07 13:59:27 -0800 | Jeff Brown / Jeff Brown | |
| Files Changed | |||||
|
MODIFY
apps/kitchen_sink_app/grails-app/controllers/commandobjects/CommandObjectsTestController.groovy
MODIFY apps/kitchen_sink_app/test/functional/commandobjects/CommandObjectsFunctionalTests.groovy |
Jeff Brown
made changes -
| Status | In Progress [ 3 ] | Closed [ 6 ] |
| Resolution | Fixed [ 1 ] |
Burt Beckwith
made changes -
| Workflow | Grails2 [ 70530 ] | jira [ 71269 ] |
Burt Beckwith
made changes -
| Workflow | jira [ 71269 ] | Grails2 [ 79419 ] |
Peter Ledbrook
made changes -
| Workflow | Grails2 [ 79419 ] | jira [ 88526 ] |
Peter Ledbrook
made changes -
| Workflow | jira [ 88526 ] | Grails2 [ 96720 ] |
The constraints block is a DSL that's parsed to infer the constraint rules. In your example "state(inList: ['active', 'loginDisabled', 'actionsDisabled'])" is actually a method call with name "state" taking a map of parameters. There's no direct way to get access to those parameters from the constraints block.