Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
githubgodot opened this issue Jan 25, 2016 · 11 comments

Comments

@githubgodot
Copy link

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
Copy link
Owner

uklance commented Jan 25, 2016

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
#28.

@githubgodot
Copy link
Author

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
#28.


Reply to this email directly or view it on GitHub
#28 (comment)
.

@uklance
Copy link
Owner

uklance commented Jan 25, 2016

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
#28.


Reply to this email directly or view it on GitHub
<
#28 (comment)

.


Reply to this email directly or view it on GitHub
#28 (comment)
.

@githubgodot
Copy link
Author

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
#28.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<
#28 (comment)

.


Reply to this email directly or view it on GitHub
#28 (comment)
.

@githubgodot
Copy link
Author

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:

  • remove the library imports "@import(library = { "atmosphere.js",
    "tapestry-atmosphere.js" })"
  • replace the line
    "javascriptSupport.addInitializerCall("atmosphereContainer", config);" in
    afterRenderBody() with the following two lines:
    ======================== begin
    String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    javascriptSupport.require(className).with(config);
    ======================== end

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:

  • remove the library import "@import(library = "Observe.js")"
  • replace afterRender() and onObserve(...) with the following:
    ======================== begin
    final private static String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    void afterRender() {
    List calculatedFields = calculateFields();
    if (calculatedFields != null) {
    String listenerURI = resources.createEventLink(className,
    event, context, ("" + fields).split(",").length).toURI();
    String clientId = container.getClientId();
    jss.require(className).with(clientId, getClientEvent(),
    listenerURI, zone, "" + calculatedFields, className);
    }
    }
    Object onObserve(String event, String context, int fieldCount) {
    List contextValues = new ArrayList();
    if (context != null) {
    contextValues.add(context);
    }
    for (int i = 0; i < fieldCount; ++i) {
    String paramName = className + i;
    contextValues.add(request.getParameter(paramName));
    }
    CaptureResultCallback callback = new
    CaptureResultCallback();
    EventContext eventContext = new StringEventContext(contextValues,
    valueEncoderSource);
    resources.triggerContextEvent(event, eventContext, callback);
    return callback.getResult();
    }
    ======================== end
  • save prettify.js (your original) and the two attached files
    ProgressLink.js and Observe.js
    ./src/main/resources/META-INF/assets/stitch/prettify.js
    ./src/main/resources/META-INF/assets/stitch/ProgressLink.js
    ./src/main/resources/META-INF/modules/Observe.js
  • the catch in both progress link and observe is the declaration of the zone
    manager and calling the deferredZoneUpdate...

    you will see that components.Errors.java imports
    org.apache.tapestry5.corelib.internal.InternalMessages which is no longer
    supported by 5.4.0.
    I fixed this by replacing "if (tracker == null) throw new
    RuntimeException(InternalMessages.encloseErrorsInForm());" with "if
    (tracker!=null)"

    I also had to avoid a couple of NullPointerExceptions in GridCollapse.java
    and GridDecorator.java where collapseColumn and
    containingDiv.find("table/tbody") can be null, but these issues are trivial
    to get by...

    kind regards, danny.

    On 25 January 2016 at 22:25, danny de cock danny.decock@gmail.com wrote:

    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
    #28.


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <
    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    #28 (comment)
    .

@uklance
Copy link
Owner

uklance commented Jan 27, 2016

Are you able to create a git patch file for your changes?

This would involve committing your changes to your local git repo then
using format-patch to generate a patch file

https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/
On 27 Jan 2016 17:36, "githubgodot" notifications@github.com wrote:

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:

  • remove the library imports "@import(library = { "atmosphere.js",
    "tapestry-atmosphere.js" })"
  • replace the line
    "javascriptSupport.addInitializerCall("atmosphereContainer", config);" in
    afterRenderBody() with the following two lines:
    ======================== begin
    String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    javascriptSupport.require(className).with(config);
    ======================== end

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:

  • remove the library import "@import(library = "Observe.js")"
  • replace afterRender() and onObserve(...) with the following:
    ======================== begin
    final private static String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    void afterRender() {
    List calculatedFields = calculateFields();
    if (calculatedFields != null) {
    String listenerURI = resources.createEventLink(className,
    event, context, ("" + fields).split(",").length).toURI();
    String clientId = container.getClientId();
    jss.require(className).with(clientId, getClientEvent(),
    listenerURI, zone, "" + calculatedFields, className);
    }
    }
    Object onObserve(String event, String context, int fieldCount) {
    List contextValues = new ArrayList();
    if (context != null) {
    contextValues.add(context);
    }
    for (int i = 0; i < fieldCount; ++i) {
    String paramName = className + i;
    contextValues.add(request.getParameter(paramName));
    }
    CaptureResultCallback callback = new
    CaptureResultCallback();
    EventContext eventContext = new StringEventContext(contextValues,
    valueEncoderSource);
    resources.triggerContextEvent(event, eventContext, callback);
    return callback.getResult();
    }
    ======================== end
  • save prettify.js (your original) and the two attached files
    ProgressLink.js and Observe.js
    ./src/main/resources/META-INF/assets/stitch/prettify.js
    ./src/main/resources/META-INF/assets/stitch/ProgressLink.js
    ./src/main/resources/META-INF/modules/Observe.js
  • the catch in both progress link and observe is the declaration of the zone
    manager and calling the deferredZoneUpdate...

    you will see that components.Errors.java imports
    org.apache.tapestry5.corelib.internal.InternalMessages which is no longer
    supported by 5.4.0.
    I fixed this by replacing "if (tracker == null) throw new
    RuntimeException(InternalMessages.encloseErrorsInForm());" with "if
    (tracker!=null)"

    I also had to avoid a couple of NullPointerExceptions in GridCollapse.java
    and GridDecorator.java where collapseColumn and
    containingDiv.find("table/tbody") can be null, but these issues are trivial
    to get by...

    kind regards, danny.

    On 25 January 2016 at 22:25, danny de cock danny.decock@gmail.com wrote:

    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
    #28.


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <
    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    #28 (comment)
    .

@githubgodot
Copy link
Author

dear lance,

the attached patch files should do the trick.
the changes to GridCollapse.java and GridDecorator.java look overwhelming,
but they are nothing more than the reindentation of the code after checking
for a null-pointer occurrence... tapestry 5.4 seems to fail if
collapseColumn (in GridCollapse) and the table body of GridDecorator are
null...

kind regards, d.

On 27 January 2016 at 19:12, Lance notifications@github.com wrote:

Are you able to create a git patch file for your changes?

This would involve committing your changes to your local git repo then
using format-patch to generate a patch file

https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/

On 27 Jan 2016 17:36, "githubgodot" notifications@github.com wrote:

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:

  • remove the library imports "@import(library = { "atmosphere.js",
    "tapestry-atmosphere.js" })"
  • replace the line
    "javascriptSupport.addInitializerCall("atmosphereContainer", config);" in
    afterRenderBody() with the following two lines:
    ======================== begin
    String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    javascriptSupport.require(className).with(config);
    ======================== end

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:

  • remove the library import "@import(library = "Observe.js")"
  • replace afterRender() and onObserve(...) with the following:
    ======================== begin
    final private static String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    void afterRender() {
    List calculatedFields = calculateFields();
    if (calculatedFields != null) {
    String listenerURI = resources.createEventLink(className,
    event, context, ("" + fields).split(",").length).toURI();
    String clientId = container.getClientId();
    jss.require(className).with(clientId, getClientEvent(),
    listenerURI, zone, "" + calculatedFields, className);
    }
    }
    Object onObserve(String event, String context, int fieldCount) {
    List contextValues = new ArrayList();
    if (context != null) {
    contextValues.add(context);
    }
    for (int i = 0; i < fieldCount; ++i) {
    String paramName = className + i;
    contextValues.add(request.getParameter(paramName));
    }
    CaptureResultCallback callback = new
    CaptureResultCallback();
    EventContext eventContext = new StringEventContext(contextValues,
    valueEncoderSource);
    resources.triggerContextEvent(event, eventContext, callback);
    return callback.getResult();
    }
    ======================== end
  • save prettify.js (your original) and the two attached files
    ProgressLink.js and Observe.js
    ./src/main/resources/META-INF/assets/stitch/prettify.js
    ./src/main/resources/META-INF/assets/stitch/ProgressLink.js
    ./src/main/resources/META-INF/modules/Observe.js
  • the catch in both progress link and observe is the declaration of the
    zone
    manager and calling the deferredZoneUpdate...

    you will see that components.Errors.java imports
    org.apache.tapestry5.corelib.internal.InternalMessages which is no longer
    supported by 5.4.0.
    I fixed this by replacing "if (tracker == null) throw new
    RuntimeException(InternalMessages.encloseErrorsInForm());" with "if
    (tracker!=null)"

    I also had to avoid a couple of NullPointerExceptions in
    GridCollapse.java
    and GridDecorator.java where collapseColumn and
    containingDiv.find("table/tbody") can be null, but these issues are
    trivial
    to get by...

    kind regards, danny.

    On 25 January 2016 at 22:25, danny de cock danny.decock@gmail.com
    wrote:

    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
    #28.


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <
    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    #28 (comment)
    .

@uklance
Copy link
Owner

uklance commented Jan 28, 2016

Hi Danny, nothing attached unfortunately.
On 28 Jan 2016 10:24, "githubgodot" notifications@github.com wrote:

dear lance,

the attached patch files should do the trick.
the changes to GridCollapse.java and GridDecorator.java look overwhelming,
but they are nothing more than the reindentation of the code after checking
for a null-pointer occurrence... tapestry 5.4 seems to fail if
collapseColumn (in GridCollapse) and the table body of GridDecorator are
null...

kind regards, d.

On 27 January 2016 at 19:12, Lance notifications@github.com wrote:

Are you able to create a git patch file for your changes?

This would involve committing your changes to your local git repo then
using format-patch to generate a patch file

https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/

On 27 Jan 2016 17:36, "githubgodot" notifications@github.com wrote:

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:

  • remove the library imports "@import(library = { "atmosphere.js",
    "tapestry-atmosphere.js" })"
  • replace the line
    "javascriptSupport.addInitializerCall("atmosphereContainer", config);"
    in
    afterRenderBody() with the following two lines:
    ======================== begin
    String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    javascriptSupport.require(className).with(config);
    ======================== end

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:

  • remove the library import "@import(library = "Observe.js")"
  • replace afterRender() and onObserve(...) with the following:
    ======================== begin
    final private static String className =
    java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
    void afterRender() {
    List calculatedFields = calculateFields();
    if (calculatedFields != null) {
    String listenerURI = resources.createEventLink(className,
    event, context, ("" + fields).split(",").length).toURI();
    String clientId = container.getClientId();
    jss.require(className).with(clientId, getClientEvent(),
    listenerURI, zone, "" + calculatedFields, className);
    }
    }
    Object onObserve(String event, String context, int fieldCount) {
    List contextValues = new ArrayList();
    if (context != null) {
    contextValues.add(context);
    }
    for (int i = 0; i < fieldCount; ++i) {
    String paramName = className + i;
    contextValues.add(request.getParameter(paramName));
    }
    CaptureResultCallback callback = new
    CaptureResultCallback();
    EventContext eventContext = new StringEventContext(contextValues,
    valueEncoderSource);
    resources.triggerContextEvent(event, eventContext, callback);
    return callback.getResult();
    }
    ======================== end
  • save prettify.js (your original) and the two attached files
    ProgressLink.js and Observe.js
    ./src/main/resources/META-INF/assets/stitch/prettify.js
    ./src/main/resources/META-INF/assets/stitch/ProgressLink.js
    ./src/main/resources/META-INF/modules/Observe.js
  • the catch in both progress link and observe is the declaration of the
    zone
    manager and calling the deferredZoneUpdate...

    you will see that components.Errors.java imports
    org.apache.tapestry5.corelib.internal.InternalMessages which is no
    longer
    supported by 5.4.0.
    I fixed this by replacing "if (tracker == null) throw new
    RuntimeException(InternalMessages.encloseErrorsInForm());" with "if
    (tracker!=null)"

    I also had to avoid a couple of NullPointerExceptions in
    GridCollapse.java
    and GridDecorator.java where collapseColumn and
    containingDiv.find("table/tbody") can be null, but these issues are
    trivial
    to get by...

    kind regards, danny.

    On 25 January 2016 at 22:25, danny de cock danny.decock@gmail.com
    wrote:

    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
    #28.


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <

    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    <
    #28 (comment)

    .


    Reply to this email directly or view it on GitHub
    #28 (comment)
    .

@githubgodot
Copy link
Author

probably stripped by github... will send the attachment to your gmail
account...

d.

On 28 January 2016 at 11:40, Lance notifications@github.com wrote:

Hi Danny, nothing attached unfortunately.

On 28 Jan 2016 10:24, "githubgodot" notifications@github.com wrote:

dear lance,

the attached patch files should do the trick.
the changes to GridCollapse.java and GridDecorator.java look
overwhelming,
but they are nothing more than the reindentation of the code after
checking
for a null-pointer occurrence... tapestry 5.4 seems to fail if
collapseColumn (in GridCollapse) and the table body of GridDecorator are
null...

kind regards, d.

On 27 January 2016 at 19:12, Lance notifications@github.com wrote:

Are you able to create a git patch file for your changes?

This would involve committing your changes to your local git repo then
using format-patch to generate a patch file

https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/

On 27 Jan 2016 17:36, "githubgodot" notifications@github.com wrote:

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:

  • remove the library imports "@import(library = { "atmosphere.js",
    "tapestry-atmosphere.js" })"
  • replace the line
    "javascriptSupport.addInitializerCall("atmosphereContainer",
    config);"
    in
    afterRenderBody() with the following two lines:
    ======================== begin
    String className =

java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
javascriptSupport.require(className).with(config);
======================== end

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:

  • remove the library import "@import(library = "Observe.js")"
  • replace afterRender() and onObserve(...) with the following:
    ======================== begin
    final private static String className =

java.lang.invoke.MethodHandles.lookup().lookupClass().getSimpleName();
void afterRender() {
List calculatedFields = calculateFields();
if (calculatedFields != null) {
String listenerURI = resources.createEventLink(className,
event, context, ("" + fields).split(",").length).toURI();
String clientId = container.getClientId();
jss.require(className).with(clientId, getClientEvent(),
listenerURI, zone, "" + calculatedFields, className);
}
}
Object onObserve(String event, String context, int fieldCount) {
List contextValues = new ArrayList();
if (context != null) {
contextValues.add(context);
}
for (int i = 0; i < fieldCount; ++i) {
String paramName = className + i;
contextValues.add(request.getParameter(paramName));
}
CaptureResultCallback callback = new
CaptureResultCallback();
EventContext eventContext = new StringEventContext(contextValues,
valueEncoderSource);
resources.triggerContextEvent(event, eventContext, callback);
return callback.getResult();
}
======================== end

  • save prettify.js (your original) and the two attached files
    ProgressLink.js and Observe.js
    ./src/main/resources/META-INF/assets/stitch/prettify.js
    ./src/main/resources/META-INF/assets/stitch/ProgressLink.js
    ./src/main/resources/META-INF/modules/Observe.js

the catch in both progress link and observe is the declaration of the
zone
manager and calling the deferredZoneUpdate...

you will see that components.Errors.java imports
org.apache.tapestry5.corelib.internal.InternalMessages which is no
longer
supported by 5.4.0.
I fixed this by replacing "if (tracker == null) throw new
RuntimeException(InternalMessages.encloseErrorsInForm());" with "if
(tracker!=null)"

I also had to avoid a couple of NullPointerExceptions in
GridCollapse.java
and GridDecorator.java where collapseColumn and
containingDiv.find("table/tbody") can be null, but these issues are
trivial
to get by...

kind regards, danny.

On 25 January 2016 at 22:25, danny de cock danny.decock@gmail.com
wrote:

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
#28.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<

#28 (comment)

.


Reply to this email directly or view it on GitHub
<
#28 (comment)

.


Reply to this email directly or view it on GitHub
#28 (comment)
.

@githubgodot
Copy link
Author

hello lance,

I had to replace the prototype specific calls Object.toJSON() and Object.evalJSON() with the atmosphere equivalent atmosphere.util.stringifyJSON() and atmosphere.util.parseJSON() calls to make it also work in the application I am developing...

the container.js in attachment works fine now...

kind regards, d.
Container.js.txt

@uklance
Copy link
Owner

uklance commented Feb 22, 2016

tapestry-atmosphere upgraded to tapestry 5.4 thanks to this pull request. Please try version 0.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants