|
[
Permalink
| « Hide
]
Christian Sprecher added a comment - 29/Oct/07 11:29 AM
Same here on W2K ...
Just tried this today (Nov 29, 2007) and I'm not getting goodness. Running on Linux and I get
java.io.FileNotFoundException: grails-app/views/keyword (Is a directory) FYI: My domain classes use full package names and are written in Java using annotations. ie. com.mycompany.Keyword.java I'm seeing this too with a really basic sample project. This is a critical issue as far as I'm concerned. How do we raise the priority?
ScaffoldTags needs to be ported to grails 1; it hasn't yet. I have an app in production that uses & depends on ST heavily on grails 0.6. Without it I'm not sure what I would of done given that I had a huge domain model that needed CRUD operations. I just recently upgraded the app to run on grails 1.0.1 which involved a couple tweaks to ST. I'm not using ST generated controllers (as you are attempting to use) so I don't know what needs to be done there. The main change I remember making was in ScaffoldTagLib.groovy (the real brains of ST), which declared the types of some parameters to be Class but grails or groovy appears to have a bug with that: GRAILS-2659
Assuming you're using grails 1.0.3, the changes needed to ScaffoldTagLib aren't so bad. For an earlier grails versions, there may be more issues. Here is what I've got. I tweaked findView() a bit to cache some things and to clarify the code. At this point I'm not entirely sure if this is necessary to fix ST but I'm providing it here any way. Here it is.
private findView(_view) { if (log.isDebugEnabled()) { log.debug "findView: "+_view } Collection view = (_view instanceof Collection) ? _view : Collections.singleton(_view); // optimization: cache the controller URI in the request to avoid // repeated calls to getControllerUri String controllerUri = request.controllerUri if (!controllerUri) { controllerUri = grailsAttributes.getControllerUri(request) request.controllerUri = controllerUri } // There needs to be a better way to do the path lookup // ORIGINAL CODE // String controllerUri = grailsAttributes.getControllerUri(request) // optimization prmms.ViewUriCache cache = prmms.ViewUriCache.getInstance() String viewKey = controllerUri + '.' + view def cachedUri = cache.get(viewKey) if (GrailsUtil.environment == GrailsApplication.ENV_PRODUCTION) { if (cachedUri || cache.containsKey(viewKey)) return cachedUri } // println("View ${viewKey} not found in cache") def viewpaths = ["${PATH_TO_VIEWS}${controllerUri}", "${PATH_TO_VIEWS}/scaffolding", "${PLUGIN_PATH_TO_VIEWS}/scaffolding"] // println "searching for ${view} in ${viewpaths}" def ctx = grailsAttributes.applicationContext def resourceLoader = ctx.containsBean('groovyPageResourceLoader') ? ctx.groovyPageResourceLoader : ctx for (p in viewpaths) { for (v in view) { def uri = "${p}/${v}" log.debug "searching for ${uri}" def resource = resourceLoader.getResource(uri) if (resource?.file?.exists()) { log.debug("found $uri at rsrc $resource") cache.put(viewKey, uri) return uri } } } log.debug "none found" cache.put(viewKey,null) return null } That "prmms.ViewUriCache" class is my own and you can modify my code above to not use it or to supply your own. Next, modify the method signatures of findUriForXXXXXX as follows: And finally, I don't know if this is necessary, but where renderType calls findUriForType, I wrap the 2nd argument "prefix" in a collection singleton like so: My description above was verified to work by a 3rd party: Torsten Kruse David, thanks for the help, but as a complete grails and groovy newby I nearly pulled a neck muscle trying to follow what you were doing up there.
So I ended up doing some debugging of my own, and this is what I have found. The view parameter that is passed in to the findView() method is not a java.lang.String but it is a groovy.lang.GString, so it falls to the else part of the if, and loops thru the characters "list/". It finds a match on the last character "/", and returns uri "/WEB-INF/grails-app/views/book//". So to fix the issue I changed the if statement to check for instanceof String OR GString, which works for the first view (list). [Fatal Error] :-1:-1: Premature end of file. even when viewing the app homepage. And secondly, when selecting the create button on the list page No signature of method: ScaffoldTagLib.findUriForType() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.Class, java.lang.String) values: {"editor", "", class java.lang.String, ""}
My code changes below, (just look for the GString): private findView(view) { // There needs to be a better way to do the path lookup String controllerUri = grailsAttributes.getControllerUri(request) def viewpaths = ["${PATH_TO_VIEWS}${controllerUri}", "${PATH_TO_VIEWS}/scaffolding", "${PLUGIN_PATH_TO_VIEWS}/scaffolding"] // println "searching for ${view} in ${viewpaths}" def ctx = grailsAttributes.applicationContext def resourceLoader = ctx.containsBean('groovyPageResourceLoader') ? ctx.groovyPageResourceLoader : ctx for (p in viewpaths) { if (view instanceof String || view instanceof GString) { def uri = "${p}/${view}" def resource = resourceLoader.getResource(uri) if (resource && resource.file && resource.file.exists()) { // println "found-1 in ${uri} at ${resource}" return uri } } else { for (v in view) { def uri = "${p}/${v}" // println "searching for ${uri}" def resource = resourceLoader.getResource(uri) if (resource && resource.file && resource.file.exists()) { // println "found-2 in ${uri} at ${resource}" return uri } } } } // println "none found" return null } Neil, thanks for the String vs GString thing you pointed out, I'll have to change my code. The "no signature of method" should go away once you modify the method signatures I mentioned in my last message. It would seem it's some kind of Groovy level issue.
The "Premature end of file" thing is a Firefox 3 related issue; there's a JIRA issue for it and a fix. Never mind my comment String vs GString... I should of compared your code with mine. I thought you simply changed by code in perhaps one line but you have a different findView implementation remeniscent of the original. See mine above.
David, you're right, I did just make the change to the original, it would be a rgeat help if you could attach the source for your prmms.ViewUriCache class.
The "Premature end of file" thing is happening on my Opera-951 too. I'm still battling with the following Message: No signature of method: ScaffoldTagLib.findUriForType() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.Class, java.lang.String) values: {"editor", "", class java.lang.String, ""}
Caused by: No signature of method: ScaffoldTagLib.findUriForType() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.Class, java.lang.String) values: {"editor", "", class java.lang.String, ""}
Class: ScaffoldTagLib
At Line: [580]
Any pointers? Neil, respectfully, if you read and followed what I said about changing the method signatures then you won't get that error. I would take my code if I were you and either ditch the ViewUriCache or implement your own. The code is as simply as you might imagine it is:
class ViewUriCache {
Map cache = Collections.synchronizedMap(new HashMap<String, String>())
static ViewUriCache instance = new ViewUriCache()
private ViewUriCache() {}
static ViewUriCache getInstance() { return instance }
String put(String key, String URI) {
return cache.put(key, URI)
}
String get(String key) {
return cache.get(key)
}
boolean containsKey(String key) {
return cache.containsKey(key)
}
}
Hi David, thanks anyway but it didn't help me.
I tried with your findView method and ViewUriCache class. It works for the list page, but after clicking the create button I still had the same error "No signature of method ...". So out of frustration I reverted back to the original (with the OR GString) and removed all of the type declarations from the findUriForType and findUriForExactClass methods, and EUREKA the create button worked. Although now I am looking at an issue with the save function. groovy.lang.MissingPropertyException: No such property: id for class: java.lang.String ... This should be a default feature if Grails. To have to update a gsp by hand once you have custom code in it should be unnecessary!
Hi,
I am working in the porting to Grails 1.1.1. I already commit some changes and the no-img-skin are ok. |
|||||||||||||||||||||||||||||||||||||||||||||