You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Woods <dw...@gmail.com> on 2011/04/15 11:58:10 UTC

Displaying a progress message while processing a zone update

Hi, I'm just getting started with Tapestry5, and very impressed so far.

I have a zone on my page containing a grid component that takes about 20
seconds to calculate the contents of.  I don't want the loading of the page
to hang while this occurs, so I initially have the contents of the zone
hidden by an "if" component associated with a boolean property for the
visibility, and have the "get" method for the grid contents conditionally
returning null when the property is set to false.  To calculate the contents
and display the zone I have an actionlink that changes the boolean property
and returns the zone body.

The toggling works fine, but what I would like to do is display a message on
the page as soon as the actionlink is clicked saying that the load is in
progress (at the moment there is no visible change for 20s), and then this
message should go away when the zone appears.  Is there a way to do this?
 Also, I would appreciate any insights into whether there is a better way to
do this...

>From the tml:

    <t:actionlink t:id="toggleDomains"
zone="domainsZone">Domains</t:actionlink>

    <t:zone t:id="domainsZone">

        <t:if test="domainsVisible">

            <t:grid source="domains" rowsPerPage="15"/>

        </t:if>

    </t:zone>


>From the page class:


     @Persist

    @Property

    private boolean domainsVisible;



    @InjectComponent

    private Zone domainsZone;



    Zone onActionFromToggleDomains() {

        domainsVisible = domainsVisible ? false : true;

        return domainsZone;

    }



    public List<Domain> getDomains() {

        if(domainsVisible) {

            return retrieveDomainList();

        }

        else {

            return null;

        }

    }


Thanks for all the interesting discussion and tips.


David

Re: Displaying a progress message while processing a zone update

Posted by David Woods <dw...@gmail.com>.
Thanks guys. I am trying to avoid javascript and to do this with tapestry components, so the ProgressiveDisplay method that François suggested seems perfect. A bit of fiddling and it's working perfectly. For the record, and for future searchers, here is the code that I used:

>From the tml:

<t:actionlink t:id="toggleDomains" zone="domainsZone">Domains</t:actionlink>
<t:zone t:id="domainsZone">
<t:if test="domainsVisible">
<t:progressivedisplay t:id="domainLoadingIndicator" update="show"/>
<t:block t:id="domainsBlock">
<t:grid source="domains" rowsPerPage="15"/>
</t:block>
</t:if>
</t:zone>


>From the page class:

@Persist
@Property
private boolean domainsVisible;

@SetupRender
void initialize() {
domainsVisible = false;
}

@InjectComponent
private Zone domainsZone;

@Inject
private Block domainsBlock;

Zone onActionFromToggleDomains(){
domainsVisible = domainsVisible ? false : true;
return domainsZone;
}

Block onProgressiveDisplayFromDomainLoadingIndicator(){
return domainsBlock;
}

public List<Domain> getDomains() {
if(domainsVisible){
return retrieveDomainList();
}
else {
return null;
}
}


David


On Friday, 15 April 2011 at 8:31 PM, François Facon wrote: 
> Use ProgressiveDisplay component?
> http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/ProgressiveDisplay.html
> 
> see example http://lombok.demon.co.uk/tapestry5Demo/test/core/progressivedisplaydemosource
> 
> or from tapestry test case
> http://tapestry-test.appspot.com/progressivedemo
> with the related src at
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ProgressiveDemo.java?view=markup
> 
> François
> 
> 
> 2011/4/15 David Woods <dw...@gmail.com>:
> > Hi, I'm just getting started with Tapestry5, and very impressed so far.
> > 
> > I have a zone on my page containing a grid component that takes about 20
> > seconds to calculate the contents of. I don't want the loading of the page
> > to hang while this occurs, so I initially have the contents of the zone
> > hidden by an "if" component associated with a boolean property for the
> > visibility, and have the "get" method for the grid contents conditionally
> > returning null when the property is set to false. To calculate the contents
> > and display the zone I have an actionlink that changes the boolean property
> > and returns the zone body.
> > 
> > The toggling works fine, but what I would like to do is display a message on
> > the page as soon as the actionlink is clicked saying that the load is in
> > progress (at the moment there is no visible change for 20s), and then this
> > message should go away when the zone appears. Is there a way to do this?
> > Also, I would appreciate any insights into whether there is a better way to
> > do this...
> > 
> > From the tml:
> > 
> > <t:actionlink t:id="toggleDomains"
> > zone="domainsZone">Domains</t:actionlink>
> > 
> > <t:zone t:id="domainsZone">
> > 
> > <t:if test="domainsVisible">
> > 
> > <t:grid source="domains" rowsPerPage="15"/>
> > 
> > </t:if>
> > 
> > </t:zone>
> > 
> > 
> > From the page class:
> > 
> > 
> >  @Persist
> > 
> > @Property
> > 
> > private boolean domainsVisible;
> > 
> > 
> > 
> > @InjectComponent
> > 
> > private Zone domainsZone;
> > 
> > 
> > 
> > Zone onActionFromToggleDomains() {
> > 
> > domainsVisible = domainsVisible ? false : true;
> > 
> > return domainsZone;
> > 
> > }
> > 
> > 
> > 
> > public List<Domain> getDomains() {
> > 
> > if(domainsVisible) {
> > 
> > return retrieveDomainList();
> > 
> > }
> > 
> > else {
> > 
> > return null;
> > 
> > }
> > 
> > }
> > 
> > 
> > Thanks for all the interesting discussion and tips.
> > 
> > 
> > David
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

Re: Displaying a progress message while processing a zone update

Posted by François Facon <fr...@atosorigin.com>.
Use ProgressiveDisplay component?
http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/ProgressiveDisplay.html

see example  http://lombok.demon.co.uk/tapestry5Demo/test/core/progressivedisplaydemosource

or from tapestry test case
http://tapestry-test.appspot.com/progressivedemo
with the related src at
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ProgressiveDemo.java?view=markup

François


2011/4/15 David Woods <dw...@gmail.com>:
> Hi, I'm just getting started with Tapestry5, and very impressed so far.
>
> I have a zone on my page containing a grid component that takes about 20
> seconds to calculate the contents of.  I don't want the loading of the page
> to hang while this occurs, so I initially have the contents of the zone
> hidden by an "if" component associated with a boolean property for the
> visibility, and have the "get" method for the grid contents conditionally
> returning null when the property is set to false.  To calculate the contents
> and display the zone I have an actionlink that changes the boolean property
> and returns the zone body.
>
> The toggling works fine, but what I would like to do is display a message on
> the page as soon as the actionlink is clicked saying that the load is in
> progress (at the moment there is no visible change for 20s), and then this
> message should go away when the zone appears.  Is there a way to do this?
>  Also, I would appreciate any insights into whether there is a better way to
> do this...
>
> From the tml:
>
>    <t:actionlink t:id="toggleDomains"
> zone="domainsZone">Domains</t:actionlink>
>
>    <t:zone t:id="domainsZone">
>
>        <t:if test="domainsVisible">
>
>            <t:grid source="domains" rowsPerPage="15"/>
>
>        </t:if>
>
>    </t:zone>
>
>
> From the page class:
>
>
>     @Persist
>
>    @Property
>
>    private boolean domainsVisible;
>
>
>
>    @InjectComponent
>
>    private Zone domainsZone;
>
>
>
>    Zone onActionFromToggleDomains() {
>
>        domainsVisible = domainsVisible ? false : true;
>
>        return domainsZone;
>
>    }
>
>
>
>    public List<Domain> getDomains() {
>
>        if(domainsVisible) {
>
>            return retrieveDomainList();
>
>        }
>
>        else {
>
>            return null;
>
>        }
>
>    }
>
>
> Thanks for all the interesting discussion and tips.
>
>
> David
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Displaying a progress message while processing a zone update

Posted by LLTYK <LL...@mailinator.com>.
A javascripty approach would be to popup the progress indicator onclick and
hide it when the ZONE_UPDATED event is fired on the zone.


Or you can look up that periodic zone refresh example, and have the zone
load over and over, with it saying "Still Loading" until the actual results
arrive. Not sure how you'd stop the periodic part when you don't need it
though.

--
View this message in context: http://tapestry-users.832.n2.nabble.com/Displaying-a-progress-message-while-processing-a-zone-update-tp6275777p6275833.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org