uklance / tapestry-atmosphere

Asynchronous WebSocket/Comet Support in Tapestry
Other
22 stars 8 forks source link

async-supported in web.xml does not seem to have any effect in tapestry 5.4.0 #28

Open githubgodot opened 8 years ago

githubgodot commented 8 years ago

I am trying to use the chat demo of tapestry-atmosphere in tapestry 5.4.0. after a little struggle to put the javascript modules in the right directories I have come to a situation where the chat demo works, but does not push the new messages to the client. the webdeveloper console shows that requirejs could not find atmosphere. this turns out to be triggered by the statement atmosphere.subscribe call in the javascript file. any idea how I can fix this? thanks, g.

uklance commented 8 years ago

I haven't tried tapestry-atmosphere in t5.4. You might want to open the developer tools in your browser (f12) and have a look in the network tab. Are all javascript files found? Or are some getting a 404?

I know t5.4 has new conventions for asset locations. Perhaps the atmosphere javascript files need to be under META-INF/assets On 25 Jan 2016 08:44, "githubgodot" notifications@github.com wrote:

I am trying to use the chat demo of tapestry-atmosphere in tapestry 540 after a little struggle to put the javascript modules in the right directories I have come to a situation where the chat demo works, but does not push the new messages to the client the webdeveloper console shows that requirejs could not find atmosphere this turns out to be triggered by the statement atmospheresubscribe call in the javascript file any idea how I can fix this? thanks, g

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28.

githubgodot commented 8 years ago

hello,

all the javascript files are found correctly: I put them in src/main/webapp and prepended the imports with the prefix "context:".

I put a couple alerts into tapestry-atmosphere.js and everything gets executed up to the line before "subsocket = atmosphere.subscribe(request);" where it reports an requirejs exception that reads require: atmosphere is not defined.

I also added a couple alerts to confirm that atmosphere.js gets loaded and executed, and it does... it seems to be a difference in scope/visibility where the tapestry-atmosphere is not able to see the atmosphere code...

when I reload the page manually, the chat messages have been processed correctly, but they are not pushed automagically without the reloading the page.

a couple of months ago, I ported most of the features of your tapestry-stitch successfully to 5.4. if you wish, I can send them to you...

thanks for your feedback, danny.

On 25 January 2016 at 10:30, Lance notifications@github.com wrote:

I haven't tried tapestry-atmosphere in t5.4. You might want to open the developer tools in your browser (f12) and have a look in the network tab. Are all javascript files found? Or are some getting a 404?

I know t5.4 has new conventions for asset locations. Perhaps the atmosphere javascript files need to be under META-INF/assets On 25 Jan 2016 08:44, "githubgodot" notifications@github.com wrote:

I am trying to use the chat demo of tapestry-atmosphere in tapestry 540 after a little struggle to put the javascript modules in the right directories I have come to a situation where the chat demo works, but does not push the new messages to the client the webdeveloper console shows that requirejs could not find atmosphere this turns out to be triggered by the statement atmospheresubscribe call in the javascript file any idea how I can fix this? thanks, g

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28.

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174447511 .

uklance commented 8 years ago

Hi Danny,

I can't say I'm that familiar with porting apps to t4.5 but it does sound like a scoping issue. Perhaps we need to create a "shim" for atmosphere so it's a require module then t5-atmosphere "require's" the atmosphere module?

a couple of months ago, I ported most of the features of your tapestry-stitch successfully to 5.4. if you wish, I can send them to you...

Great! I've been meaning to do that myself but never found the time. Please send a pull request through github. Thanks! On 25 Jan 2016 10:00, "githubgodot" notifications@github.com wrote:

hello,

all the javascript files are found correctly: I put them in src/main/webapp and prepended the imports with the prefix "context:".

I put a couple alerts into tapestry-atmosphere.js and everything gets executed up to the line before "subsocket = atmosphere.subscribe(request);" where it reports an requirejs exception that reads require: atmosphere is not defined.

I also added a couple alerts to confirm that atmosphere.js gets loaded and executed, and it does... it seems to be a difference in scope/visibility where the tapestry-atmosphere is not able to see the atmosphere code...

when I reload the page manually, the chat messages have been processed correctly, but they are not pushed automagically without the reloading the page.

a couple of months ago, I ported most of the features of your tapestry-stitch successfully to 5.4. if you wish, I can send them to you...

thanks for your feedback, danny.

On 25 January 2016 at 10:30, Lance notifications@github.com wrote:

I haven't tried tapestry-atmosphere in t5.4. You might want to open the developer tools in your browser (f12) and have a look in the network tab. Are all javascript files found? Or are some getting a 404?

I know t5.4 has new conventions for asset locations. Perhaps the atmosphere javascript files need to be under META-INF/assets On 25 Jan 2016 08:44, "githubgodot" notifications@github.com wrote:

I am trying to use the chat demo of tapestry-atmosphere in tapestry 540 after a little struggle to put the javascript modules in the right directories I have come to a situation where the chat demo works, but does not push the new messages to the client the webdeveloper console shows that requirejs could not find atmosphere this turns out to be triggered by the statement atmospheresubscribe call in the javascript file any idea how I can fix this? thanks, g

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28.

— Reply to this email directly or view it on GitHub < https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174447511

.

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174456633 .

githubgodot commented 8 years ago

hello,

the shim-thing sounds promising indeed...

wrt tapestry-stitch: I will create a diff between my 5.4 version and your github version. I have no experience with pull requests, but will give it a try...

thanks & cu later, d.

On 25 January 2016 at 15:29, Lance notifications@github.com wrote:

Hi Danny,

I can't say I'm that familiar with porting apps to t4.5 but it does sound like a scoping issue. Perhaps we need to create a "shim" for atmosphere so it's a require module then t5-atmosphere "require's" the atmosphere module?

a couple of months ago, I ported most of the features of your tapestry-stitch successfully to 5.4. if you wish, I can send them to you...

Great! I've been meaning to do that myself but never found the time. Please send a pull request through github. Thanks!

On 25 Jan 2016 10:00, "githubgodot" notifications@github.com wrote:

hello,

all the javascript files are found correctly: I put them in src/main/webapp and prepended the imports with the prefix "context:".

I put a couple alerts into tapestry-atmosphere.js and everything gets executed up to the line before "subsocket = atmosphere.subscribe(request);" where it reports an requirejs exception that reads require: atmosphere is not defined.

I also added a couple alerts to confirm that atmosphere.js gets loaded and executed, and it does... it seems to be a difference in scope/visibility where the tapestry-atmosphere is not able to see the atmosphere code...

when I reload the page manually, the chat messages have been processed correctly, but they are not pushed automagically without the reloading the page.

a couple of months ago, I ported most of the features of your tapestry-stitch successfully to 5.4. if you wish, I can send them to you...

thanks for your feedback, danny.

On 25 January 2016 at 10:30, Lance notifications@github.com wrote:

I haven't tried tapestry-atmosphere in t5.4. You might want to open the developer tools in your browser (f12) and have a look in the network tab. Are all javascript files found? Or are some getting a 404?

I know t5.4 has new conventions for asset locations. Perhaps the atmosphere javascript files need to be under META-INF/assets On 25 Jan 2016 08:44, "githubgodot" notifications@github.com wrote:

I am trying to use the chat demo of tapestry-atmosphere in tapestry 540 after a little struggle to put the javascript modules in the right directories I have come to a situation where the chat demo works, but does not push the new messages to the client the webdeveloper console shows that requirejs could not find atmosphere this turns out to be triggered by the statement atmospheresubscribe call in the javascript file any idea how I can fix this? thanks, g

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28.

— Reply to this email directly or view it on GitHub <

https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174447511

.

— Reply to this email directly or view it on GitHub < https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174456633

.

— Reply to this email directly or view it on GitHub https://github.com/uklance/tapestry-atmosphere/issues/28#issuecomment-174523382 .

githubgodot commented 8 years ago

dear lance,

I am very happy that I can inform you that I got the tapestry-atmosphere demo 0.0.6 working with tapestry 5.4.0. it was a little cumbersome to find the right file locations and fixes, but it works now...

I also include the changes to tapestry-stitch for 5.4.0.

the changes are relatively minimal once one has figured out how and where the stuff has to go and how it should be called ;-)

changes wrt components.Container.java:

the className evaluates to "Container", but by calling getSimpleName the code becomes copy/pastable and independent of a hardcoded string

subsequently, you have to save the atmosphere.js and Container.js into src/main/resources/META-INF/modules and you are done... your original tapestry-atmosphere is wrapped into a module-like structure, but the real catch to get it to work properly was the subsocket assignment: ======================== begin require(['atmosphere'], function(atmosphere) { subsocket = atmosphere.subscribe(request) }); ======================== end

making the javascript files of your tapestry-stitch compatible with tapestry 5.4.0 goes as follows:

changes wrt mixins.Observe.java: