tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Balázs Palcsó <palcso.bal...@gmail.com>
Subject Refreshing zone in layout triggered by an eventlink in a nested component.
Date Thu, 14 Feb 2019 21:23:40 GMT
Hello,

Refreshing totalPointsZone from the FullWidthLayout is not working when
participateInSweepstake  async eventlink is clicked
in sweepstake.ShowSweepstake nested component.

Any suggestions how to get both the participateInSweepstakeZone and the
totalPointsZone refreshed when <t:EventLink event="participateInSweepstake"
context="${sweepstake.id}" async="true">Participate is clicked</t:EventLink>

*Here is the relevant code snippets from the app:*

*Page: ShowSweepstakes.tml file:*
<html t:type="layout" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_4.xsd">
    <t:sweepstake.ShowSweepstakes  />
</html>

*sweepstake.ShowSweepstakes.tml component:*
<t:container>
    <loop>
         <t:sweepstake.ShowSweepstake sweepstake="sweepstake"  />
   </loop>
</t:container>

*sweepstake.ShowSweepstake.tml component:*
   <t:zone t:id="participateInSweepstakeZone"
id="prop:participateInSweepstakeZoneId">
            <t:if test="notParticipatedYet">
                <t:EventLink event="participateInSweepstake" context="${
sweepstake.id}" async="true" class="btn btn-danger btn-lg">
                    Participate for
${sweepstake.priceToParticipateInPoints} points
                </t:EventLink>
            <p:else>
                <button type="button" class="btn btn-danger btn-lg"
disabled="disabled">You're already participating</button>
            </p:else>
            </t:if>
        </t:zone>

*ShowSweepstake .java:*
public class ShowSweepstake {
    @CommitAfter
    void onParticipateInSweepstake(final Sweepstake sweepstake) {
         ....

componentResources.triggerEvent(ComponentEvents.REFRESH_TOTAL_POINTS, null,
null);
        if (request.isXHR()) {
            ajaxResponseRenderer.addRender(participateInSweepstakeZone);
        }
    }

*Layout.tml component*
<html t:type="FullWidthLayout">
    <div id="layout-container" class="container">
        <div class="row">
            <t:body />
        </div>
    </div>
</html>

*FullWidthLayout.tml component:*
<html><body>
    *<span t:type="zone" t:id="totalPointsZone">${user.totalPoints}</span>*
    <t:body />
</body> </html>

*FullWidthLayout .java component*
public class FullWidthLayout {
    *@OnEvent(ComponentEvents.REFRESH_TOTAL_POINTS)*
    private void refreshTotalPoints() {
        ajaxResponseRenderer.addRender(totalPointsZone);
    }
}

Thanks,
Balazs

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message