I'm desperately seeking an up-to-date example of custom javascript, because 
nothing I've tried works.  Here's one attempt that failed...

package myapp.pages;

import javax.inject.Inject;

import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

@Import(stack = { "core" }, library = { "stuff.js" })
public class Index2 {

        @Inject
        private JavaScriptSupport jsSupport; 

        void afterRender() {
                JSONObject params = new JSONObject();
                jsSupport.require("pages/stuff").with(params);
        }

}

...In my WAR is /META-INF/modules/pages/stuff.js...

define(["jquery", "t5/core/console"], function($, console) {
        return function(params) {
                console.warn("jQuery version: " + $().jquery);
        };
});

...The javascript console shows good news...

Loading library /myapp/asset.gz/app/495033b1/pages/stuff.js

...followed by bad news...

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://gc1.local:8080/myapp/asset.gz/module/pages/stuff.js

Cheers,

Geoff


Reply via email to