got5/tapestry5-jquery — Issue #114: Component's import inside a block doesn't work
Author: iberck
Created: 2011-12-21 21:03:59+00:00
State: open

When you put a component inside a block, the libraries imported inside the component are not loaded, then appears the next error:
"Ajax failure: Status 200 for #{request.url}: TypeError: Cannot call method 'apply' of undefined
Communication with the server failed: TypeError: Cannot call method 'apply' of undefined"
The error is because the library JSLib.js is not loaded

The example works fine when I not use blocks or when I use tapestry core components, This is the scenario:

Test.tml:
-----------------------------------------------------------------------------

refresh

Component loaded

-----------------------------------------------------------------------------

Test.java:
-----------------------------------------------------------------------------
public class Test {
@Inject
private Block block1;

Object onActionFromRefresh() {
return block1;
}
}
-----------------------------------------------------------------------------

Component1.java:
-----------------------------------------------------------------------------
@Import(library = {"JSLib.js"})
public class Component1 {

@Inject
private JavaScriptSupport jsSupport;

void beginRender() {
JSONObject spec = new JSONObject();

jsSupport.addInitializerCall("loading", spec);
}
}
-----------------------------------------------------------------------------

JSLib.js:
-----------------------------------------------------------------------------
(function( $ ) {

T5.extendInitializers(function(){

function init(params) {
alert("loading");
}

return {
loading : init
}
});

}) ( jQuery );
-----------------------------------------------------------------------------

Regards