domainSuffix ignored by views #10023

Closed
madeupname opened this Issue Jul 2, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@madeupname

Environment:
Windows 8.1
jdk1.8.0_92
Grails 3.1.7

I have upgraded an app from 2.4 to 3.1.7 and notice issues with scaffolding. In my 2.4 app, I had in Config.groovy:

grails.scaffolding.templates.domainSuffix = 'Instance'

And I'm pretty sure that was added by default, which means this will affect a lot of people.

In my controller's index method (rendered by default with the list scaffolding view), this line worked:

    respond possibleDups, model: [companyInstanceCount: Company.count()]

possibleDups is a list that corresponded with companyInstanceList, and the view rendered perfectly.

After upgrading to 3.1.7, both the main body (list) and pagination were empty. After testing, I discovered the following:

  1. domainSuffix appears to change the model name, but not the corresponding variables in the view. Instead of expecting companyInstanceList and companyInstanceCount, it wants companyList and companyCount
  2. adding domainSuffix to application.yml as such did not change this.

grails:
    codegen:
        defaultPackage: com.madeupname.web
    scaffolding:
        templates:
            domainSuffix: Instance

I tested by explicitly setting model variable names::

[companyInstanceList: possibleDups, companyInstanceCount: Company.count()]

domainSuffix is also ignored in static scaffolding, as views generated with

grails generate-views com.madeupname.web.Company

look for companyList, not companyInstanceList, etc.

Right now, the workaround is to:

  1. remove domainSuffix from config
  2. Update all your controllers to remove the word Instance from model variable names

If this was intentional, the Upgrading and Scaffolding sections of the documentation should be updated to prevent confusion.

@jeffbrown

This comment has been minimized.

Show comment
Hide comment
@jeffbrown

jeffbrown Jul 6, 2016

Member

I believe that is all behaving as expected except for the fact that the scaffolding plugin doesn't take grails.scaffolding.templates.domainSuffix into account. Is that correct?

Member

jeffbrown commented Jul 6, 2016

I believe that is all behaving as expected except for the fact that the scaffolding plugin doesn't take grails.scaffolding.templates.domainSuffix into account. Is that correct?

@madeupname

This comment has been minimized.

Show comment
Hide comment
@madeupname

madeupname Jul 6, 2016

Yes, I think if dynamic scaffolding views respected the domainSuffix setting (as they do in 2.4) all would be good.

Yes, I think if dynamic scaffolding views respected the domainSuffix setting (as they do in 2.4) all would be good.

@jeffbrown

This comment has been minimized.

Show comment
Hide comment
@jeffbrown

jeffbrown Jul 6, 2016

Member

This issue should probably be filed against the plugin.

Member

jeffbrown commented Jul 6, 2016

This issue should probably be filed against the plugin.

@madeupname

This comment has been minimized.

Show comment
Hide comment
@madeupname

madeupname Jul 7, 2016

In JIRA, I (or an admin) would move this to the correct project, but I don't see a way to do that here. Can you do that?

In JIRA, I (or an admin) would move this to the correct project, but I don't see a way to do that here. Can you do that?

@jeffbrown

This comment has been minimized.

Show comment
Hide comment
@jeffbrown

jeffbrown Jul 7, 2016

Member

In JIRA, I (or an admin) would move this to the correct project, but I don't see a way to do that here. Can you do that?

I don't think so. I will just close this issue. Feel free to create a similar one at https://github.com/grails3-plugins/scaffolding/issues if you like.

Member

jeffbrown commented Jul 7, 2016

In JIRA, I (or an admin) would move this to the correct project, but I don't see a way to do that here. Can you do that?

I don't think so. I will just close this issue. Feel free to create a similar one at https://github.com/grails3-plugins/scaffolding/issues if you like.

@jeffbrown jeffbrown closed this Jul 7, 2016

@madeupname madeupname referenced this issue in grails3-plugins/scaffolding Jul 8, 2016

Open

domainSuffix ignored by views #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment