Bamboo Suite, version 1.6

This is the archives. For the latest Bambookit GUI 2.0, XML GUI Demos & Tutorials visit: www.bambookit.com/_demo.html

Using PHP to generate XML-based thin client GUI's
Version 1.6

Using PHP script to dynamically set values
View without frames



In the applet above the mailing list application is displayed. Type an e-mail in the 'subscribe me' Edit control and click on 'submit' button. The e-mail will be sent to support@bambookit.com with a subject line set to 'testing script', and the message will be displayed in the status bar. The e-mail addresses(emailto and emailfrom) and a subject line are set in XML file (emailsubmit.xml), as you can see in the code snippet provided below. Once the e-mail is successfully sent, the 'submit' button is disabled. This is to prevent the users overload bambookit support with superfulous e-mails. You can easily change it by setting setEnable="true" for 'Submit' button in the 'emailsubmit.php' file, line 17 in the second code snippet provided below.

Note: even though in this example we use PHP, any scripting language can be used to generate the xml code (i.e. Perl, PHP, ASP, JSP, ColdFusion, etc...)

download source for version 1.6
download source for version 2.0


The following XML file (emailsubmit.xml) is the initial file loaded (version 1.6)
The following program will call the script 'emailsubmit.php' script while passing the values from taken from the widgets named, 'email', 'emailfrom', 'emailto' and 'subject' (lines 04,05,06,07)

On line 08 the actual attribute that makes the call to the script, addActionTarget reads;
execute the method 'loadGui' on the 'mainpanel' widget (Line 02) whenever the 'action' event is triggered (the action event is triggered on the mousereleased or the keyreleased event on the button).

The values passed are set on Line 08 in the Button submit, and is set by the setData attribute (the %2c is an encoded comma, this is necessary otherwise it would appear to the parser that your are trying to call the method setData that takes four parameters (i.e. setData(string,string,string,string) ) however setData ONLY takes a single parameter, so as not to confuse the Bambookit parser, we encode the commas

The following php file (emailsubmit.php) is the script that is called to process the file (version 1.6)
The output of this script is an XML file that is loaded by the Bambookit GUI. We will highlight specific aspects of this script

Line 02 retrieves the client IP (sometimes this IP is the address of the ISP that the client is dialing from, to obtain a more comprehensive check, check the various refrences available to php.)

Line 03 retrieves the data passed in the URL string (PHP 4 and higher requires that you specify the values you wish to retrieve, in older versions this was not necessary)

Line 04 does a very simple check to verify a valid email address, if the email string contains the '@' sign then we would assume it is a valid email address

Line 09, this is the actual call to send an email notification to $emailto with the body of $email and the IP address $domain passed along

Line 11, do NOT name the widget 'mainpanel', this is important because this widget is a child of the original widget named 'mainpanel'. Also if we name it 'mainpanel' we would get the undesirable effect of nested children, by executing the loadGui method it would add itself to the child 'mainpanel' and not the parent 'mainpanel'.

Line 13 could easily be updated to reflect the current $email value instead of hardcoding the string 'test@email.ca'. This is left as an exercise (for guidance look at line 18)

Line 17 since this email was succesfully sent we disabled the button, setEnabled="false"

Line 18 in the status bar we indicate that the email was successfully sent and we also post the client IP address.

Line 23 this widget is sent if the email is invalid (missing the '@' symbol), the only difference is that the submit button remains enabled and the label in the statusbar is different

Using PHP to generate XML-based thin client GUI Tutorial sampl example to demonstrate how to create think client application in XML using PHP in a cross-platform solution.


[Home][Tutorial] [Reference] Demo [FAQ] [Contact Us]
Introduction