grails-angular-scaffolding icon indicating copy to clipboard operation
grails-angular-scaffolding copied to clipboard

missing resources when generating static scaffolding

Open corinnekrych opened this issue 12 years ago • 12 comments

Hello Robert

Tried to use static scaffolding without success/

  • get grails-angular-scaffolding from git hub
  • create a new grals project *update buildConfig.groovy adding grails.plugin.location."angular-scaffolding" = "/home/corinne/work/workspace/grails-angular-scaffolding"
  • create a domain class
  • use ng-install-templates
  • use ng-generate-all pkge.domainClass (* not supported)
  • launch the app

When accessing URL http://localhost:8080/toto2/person/index#/list, bumped into JS errors:

Error: Failed to load template: /ng-templates/alert.html ("",404,(function (name) {"use strict";if (!headersObj) {headersObj = parseHeaders(headers);}if (name) {return headersObj[lowercase(name)] || null;}return headersObj;}),[object Object])@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:4363 ([object Object])@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:8631 ([object Object])@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:6594 ([object Object],(void 0))@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:6670 ((function () {"use strict";result.resolve((errback || defaultErrback)(reason));}))@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:7769 ()@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:7641 ()@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:7855 done(404,"","Server: Apache-Coyote/1.1\nContent-Length: 0\nDate: Sun, 01 Jul 2012 17:24:27 GMT\n")@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:8844 completeRequest(done,404,"","Server: Apache-Coyote/1.1\nContent-Length: 0\nDate: Sun, 01 Jul 2012 17:24:27 GMT\n")@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:8984 ([object Event])@http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js:8955

http://localhost:8080/toto2/static/plugins/angular-scaffolding-1.0-SNAPSHOT/js/angular/angular-1.0.0.js Line 5525

corinnekrych avatar Jul 01 '12 17:07 corinnekrych

http://localhost:8080/ng-templates/alert.html http://localhost:8080/toto2/person/indexlist causing a 404

corinnekrych avatar Jul 01 '12 22:07 corinnekrych

The problem with http://localhost:8080/ng-templates/alert.html being a 404 is caused because I've been lazy and hardcoded the path in 2 places in the scaffolding.js file. I'll get that fixed.

In the mean time you could work around it by setting grails.app.context = '/' in your Config.groovy which will mean the apps run off the root and therefore the hardcoded paths will work.

I'm a bit worried that you're ending up with the URL person/index#/list as the index should be getting removed - it should be person#/list.

robfletcher avatar Jul 02 '12 07:07 robfletcher

I've raised #17 to track the issue with the hardcoded paths.

robfletcher avatar Jul 02 '12 07:07 robfletcher

indeed fix #17 is just fine not need to use root context any more.

Still a 404 on http://localhost:8080/toto2/person/indexlist http://localhost:8080/toto2/person/indexsave

I initially supposed the problem was located in index.gsp generated for the view, but still get redirected to indexlist. BTW do we still need a gsp file. would be nice to get rid of it completely.

on the harcoded part, "Album List" label on list.html and show.html.

corinnekrych avatar Jul 02 '12 21:07 corinnekrych

I don't understand where those URLs are coming from. They are not correct. Can you post some of the code so I can try to recreate this?

robfletcher avatar Jul 03 '12 05:07 robfletcher

I raised #18 for supporting i18n. I know this needs to be done but the plugin is still at a fairly early stage.

robfletcher avatar Jul 03 '12 05:07 robfletcher

Can run this command in the javascript console and let me know what the output is:

$('body').data('base-url')

For example, on the demo app the result is "/album/". I would expect yours to be "/toto2/person/".

robfletcher avatar Jul 03 '12 07:07 robfletcher

$('body').data('base-url') "/toto2/person/index"

corinnekrych avatar Jul 03 '12 21:07 corinnekrych

Here 's my demo exemple (one of them). nothing much...

2012/7/3 Rob Fletcher < [email protected]

Can run this command in the javascript console and let me know what the output is:

$('body').data('base-url')

For example, on the demo app the result is "/album/". I would expect yours to be "/toto2/person/".


Reply to this email directly or view it on GitHub:

https://github.com/robfletcher/grails-angular-scaffolding/issues/16#issuecomment-6728120

corinnekrych avatar Jul 03 '12 21:07 corinnekrych

Ok, that base-url value is incorrect which is partly the problem. I say partly because the URLs that are getting a 404 should have a # in them as well, e.g. http://localhost:8080/toto2/person#/list.

The base-url is set on the body tag in the ng-app.gsp layout file. It can also be overridden by setting data-base-url="whatever" in the index.gsp file. Have you changed that from the default value?

robfletcher avatar Jul 03 '12 21:07 robfletcher

I think the problem is that in the ng-app.gsp, this line data-base-url="${pageProperty(name: 'body.data-base-url', default: createLink(action: 'index').replaceAll(/index$/, ''))}" should be data-base-url="${pageProperty(name: 'body.data-base-url', default: createLink(action: 'index').replaceAll(/index$/, ''))}"

liquidchen avatar Sep 04 '12 09:09 liquidchen

@liquidchen I can't see a difference between those two lines

robfletcher avatar Sep 27 '12 11:09 robfletcher