robfletcher / grails-angular-scaffolding

A Grails plugin for scaffolding views using Angular.js
http://grails-ng.cloudfoundry.com/
87 stars 43 forks source link

missing resources when generating static scaffolding #16

Open corinnekrych opened 12 years ago

corinnekrych commented 12 years ago

Hello Robert

Tried to use static scaffolding without success/

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 commented 12 years ago

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

robfletcher commented 12 years ago

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 commented 12 years ago

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

corinnekrych commented 12 years ago

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.

robfletcher commented 12 years ago

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 commented 12 years ago

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

robfletcher commented 12 years ago

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/".

corinnekrych commented 12 years ago

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

corinnekrych commented 12 years ago

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

2012/7/3 Rob Fletcher < reply@reply.github.com

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

robfletcher commented 12 years ago

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?

liquidchen commented 12 years ago

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$/, ''))}"

robfletcher commented 12 years ago

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