Tapestry 5
  1. Tapestry 5
  2. TAP5-1949

Alerts component does not show alerts added from a component that occurs later in the template

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.3.3, 5.3.4, 5.4
    • Fix Version/s: 5.3.5, 5.4
    • Component/s: tapestry-core
    • Labels:

      Description

      Consider the following snippet:

      <t:alerts />
      <t:componentthataddsanalert />

      The alert will not be shown as the JS for the alerts is generated in the beginRender phase of the alerts component. and alerts that are added later are ignored until its next rendering.

        Activity

        Hide
        Jochen Kemnade added a comment -

        patch that defers the alerts JS initialization to allow for alerts being added by components that occur later in the template

        Show
        Jochen Kemnade added a comment - patch that defers the alerts JS initialization to allow for alerts being added by components that occur later in the template
        Hide
        Jochen Kemnade added a comment -

        Same problem and fix for 5.4

        Show
        Jochen Kemnade added a comment - Same problem and fix for 5.4
        Hide
        Howard M. Lewis Ship added a comment -

        What is your use case where new Alerts are generated during the render of the page?

        Show
        Howard M. Lewis Ship added a comment - What is your use case where new Alerts are generated during the render of the page?
        Hide
        Jochen Kemnade added a comment -

        The term "during the render of the page" is somewhat misleasing. The alerts are generated during the setup-render phase of an embedded component. The exact use case is a component whose rendering is effected by users's settings. There can be misconfigurations (related to conflicts between session state and persisted settings) that lead to a message being displayed to the user. As the component detects that error itself, it registers an alert with the alert manager. But if the alerts component is contained in the layout component, its begin-render phase (which generated the client-side JS for the alerts to be shown) is executed before the component's setup-render, so the messages are not added.

        Show
        Jochen Kemnade added a comment - The term "during the render of the page" is somewhat misleasing. The alerts are generated during the setup-render phase of an embedded component. The exact use case is a component whose rendering is effected by users's settings. There can be misconfigurations (related to conflicts between session state and persisted settings) that lead to a message being displayed to the user. As the component detects that error itself, it registers an alert with the alert manager. But if the alerts component is contained in the layout component, its begin-render phase (which generated the client-side JS for the alerts to be shown) is executed before the component's setup-render, so the messages are not added.
        Hide
        Massimo Lusetti added a comment -

        I like the proposed behavior. Did anyone see a draw back in this changes?

        Show
        Massimo Lusetti added a comment - I like the proposed behavior. Did anyone see a draw back in this changes?
        Hide
        Massimo Lusetti added a comment -

        Would you mind to flag the patch as Apache licensed?

        Show
        Massimo Lusetti added a comment - Would you mind to flag the patch as Apache licensed?
        Hide
        Jochen Kemnade added a comment -

        If I am not mistaken, I've already done that, at least the attachment management says so.

        Show
        Jochen Kemnade added a comment - If I am not mistaken, I've already done that, at least the attachment management says so.
        Hide
        Massimo Lusetti added a comment -

        Cool... I don't see the apache flag but I'll take your comment as the agreement

        Show
        Massimo Lusetti added a comment - Cool... I don't see the apache flag but I'll take your comment as the agreement
        Hide
        Massimo Lusetti added a comment -

        Thanks for the patch Joachen Kemnade

        Show
        Massimo Lusetti added a comment - Thanks for the patch Joachen Kemnade
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #814 (See https://builds.apache.org/job/tapestry-trunk-freestyle/814/)
        TAP5-1949 Defer alerts initialization to catch them all (Revision ec216f2a0e6684fc7c747603894e218bd6ec514d)

        Result = FAILURE
        mlusetti :
        Files :

        • tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
        • tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AlertsDemo.java
        • tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/ErrorComponent.java
        • tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml
        • tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #814 (See https://builds.apache.org/job/tapestry-trunk-freestyle/814/ ) TAP5-1949 Defer alerts initialization to catch them all (Revision ec216f2a0e6684fc7c747603894e218bd6ec514d) Result = FAILURE mlusetti : Files : tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AlertsDemo.java tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/ErrorComponent.java tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy

          People

          • Assignee:
            Massimo Lusetti
            Reporter:
            Jochen Kemnade
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development