tags:

views:

60

answers:

2

Can you use the package name to differentiate between classes in grails?

e.g. com.business.appName.DomainClass and com.business.appName.foo.DomainClass?

I think that this causes problems as grails needs unique class names. If you try this out it tries to overwrite the view gsps for the com.business.appName.DomainClass when you try to generate the views for the com.business.appName.foo.DomainClass

Is there a way to have the same domain class name in different packages?

A: 

If there is problem in your gsp, try by declaring at the top

<%@ page import="com.thePackageIWant.TheClassIWant" %>

Edit: Have you tried to specify the package when generating views?

grails generate-views com.business.appName.foo.DomainClass

Sorry, I am a newbie in Grails so I may not be able to help you more :(

ccheneson
You have misunderstood the problem. There are two domain classes with the same name, but in separate packages. When you generate the views the generation of the view for the second domain class overwrites the view for the first domain class.
Paul
+1  A: 

The problem is that controller names have to be unique. Running 'generate-controller' or 'generate-all' for the two domain classes with the same name in different packages creates two different controllers each in its own package, but they'll both map to /yourapp/domainClass URLs and will both share the grails-app/views/domainClass GSP folder.

You'll need to rename one of the controllers anyway since you can't have two with the same name even in different packages and can't fix this even in URLMappings, so it looks like your best bet if you want to use the generated code is to generate the first set and move the controller and views out of the way, then generate the second set. Then rename one or both of the controllers so they'll have unique URLs and rename the corresponding GSP folders.

Burt Beckwith