Bambookit Home    Middleware

Chapter 19. Middleware




Server Side Progress Bar Script Example(PHP)

The example above demonstrates how to create a script that is capable of providing an update to a progress bar. Lets say you have 2 panels, panel1 is the view that is being computed on the server side and panel2 could be the progress bar at the bottom right. When you click on the 'Load' button, two seperate actions occur: one calls the loadGui (progresslong.php, see source below) for the panel widget, the other calls the setPoll (progressupdate.php, see source below)for the progressbar widget.

Two actions get started, one for the loadGui of the panel1 and two for the polling of the statusbar, this poll will be accessing a script that can monitor the status of the original thread. (Or could just be a dummy progress).

HTML Source: <applet codebase="../../../" archive="bamboo_b384.jar" code="Loader.class" width="400" height="430"> <param name="loadgui" value="progressbar.xml"> </applet> The 'progressbar.xml' Source: <?xml version="1.0"?> <Widget setSize="400,430" setBackground="dfd6f7"> <Widget setCache="false" setName="panel" setShape="10,10,380,330" setBorder="roundraised"/> <Widget setCache="false" setName="progressbar" setShape="10,360,280,25" setBorder="roundlowered"/> <Button setShape="310,360,80,25" setLabel="Load" setFontStyle="bold" addActionTarget="action,panel, loadGui='progresslong.php,true',action,progressbar,setPoll='1%2cprogressupdate.php'"/> <Button setShape="10,390,120,25" setLabel="XML Source" addActionTarget="this,action, loadUrl='progressbar.xml'"/> <Button setShape="135,390,120,25" setLabel="loadGUI PHP Source" addActionTarget="this,action, loadUrl='progresslong.php'"/> <Button setShape="260,390,120,25" setLabel="setPoll PHP Source" addActionTarget="this,action, loadUrl='progressupdate.php'"/> </Widget> The 'progresslong.php' Source: <?php sleep(20); ?> <Widget setName="panel" setLabel="Finished loading <?php echo time();?>" addActionTarget="null,progressbar, setPoll='0%2cprogressupdate.php'"/> The 'progressupdate.php' Source: <Widget setName="progressbar" setLabel="<?php echo time();?>"/>