apache / apache/grails-core

Display Tag does not render 'id', 'dateCreated' and 'lastUpdated' fields.

Open
#14,215 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Following the work done on grails/fields#257

You would except to be able to do something like this:
` `

and see id, dateCreated, and dateUpdated

Furthermore, I believe you would expect `FormFieldsTagLib.resolvePersistentProperties` to call domainModelService.geOutputProperties(domainClass)`

as it is defined as `The list of {@link DomainProperty} instances that are to be visible`

I realize that there should be some synergy between the edit and the view page and such a change could be followed by requiring attrs.except like was done for grails/fields#257 However, it is a feature I am constantly looking for because I have no way of knowing the dateCreated and dateUpdated as well as the id (unless I look at the url).

Since the display tag already calls `FormFieldsTagLib.resolvePersistentProperties` implementing this fix is as simple as

1. Creating an `enum FormFieldsTagLib.PropertiesType = { LIST, OUTPUT, INPUT }`
2. Changing
`private List resolvePersistentProperties(PersistentEntity domainClass, Map attrs, boolean list = false) {`
to
`private List resolvePersistentProperties(PersistentEntity domainClass, Map attrs, PropertiesType propertiesType = PropertiesType.INPUT ) {`

and modifying the method
`
properties = propertiesType == PropertiesType.LIST ? domainModelService.getListOutputProperties(domainClass) : propertiesType == PropertiesType.INPUT ?
domainModelService.getInputProperties(domainClass) : domainModelService.getOutputProperties(domainClass)
// If 'except' is not set, but 'list' is, exclude 'id', 'dateCreated' and 'lastUpdated' by default
List blacklist = attrs.containsKey('except') ? getList(attrs.except) : (propertiesType == PropertiesType.LIST ? ['id', 'dateCreated', 'lastUpdated'] : [])
`

Then changing the existing calls to `FormFieldsTagLib.resolvePersistentProperties`
in 2 locations

`def display = { attrs, body ->`

`resolvePersistentProperties(domainClass, attrs, PropertiesType.OUTPUT)`

and
`private List resolvePropertyNames(PersistentEntity domainClass, Map attrs) { `

`List properties = resolvePersistentProperties(domainClass, attrs, PropertiesType.INPUT)*.name`

Contributor guide

Open the contributing guide

Research direction

Start in FormFieldsTagLib at resolvePersistentProperties, then inspect the display closure and resolvePropertyNames call sites named in the issue. Verify how output, input, and list properties are selected, and confirm that the display tag renders id, dateCreated, and lastUpdated while existing input and list behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.