WML Bigromu

This will help you build Learn WML,Learn WAP applications...Learn WML,Learn Wireless,Understand Markup Language Tutorial, Wireless Application Protocol Tutorial, Building WAP sites tutorial, Building Wireless Application Protocol Website tutorial, Web Site tutorial, Wap Site tutorial, Wap tutorial, WAP tutorial, Site Mobile tutorial, Mobile Site Tutorial, PDA SITE,

Saturday, December 09, 2006

A simple HAWHAW code

Create a new file in the same directory where hawhaw.inc is located. Use an editor of your choice to write the following PHP script:

require("hawhaw.inc");
$myPage = new HAW_deck("FAQ Demo");
$myText = new HAW_text("Hello WAP!");
$myPage->add_text($myText);
$myPage->create_page();
?>

Store this file as test.php. (Alternatively you can save your file as test.wml if you have administered your webserver to activate PHP for .wml extensions.)

What is the meaning of these few instructions? Before you can use any HAWHAW function calls, you have to include the hawhaw.inc file. Afterwards you have to define one so-called HAW_deck object. The whole HAWHAW API follows a strict object-oriented approach. There are some objects like HAW_deck or HAW_text. And there are object functions, to perform actions on those objects. So what we do in line 3 of our tiny example is: We define $myPage as an object of the class HAW_deck. When you take a look at the HAWHAW reference, you will see that the constructor of HAW_deck optionally awaits some title for your 'deck'. Btw, a deck is an expression that is often used in the WAP terminology. In HAWHAW's context you don't have to distinguish between deck and page. It is the same.

When you examine the HAW_deck constructor in the reference in detail, you will notice, that there is another optional input parameter alignment. If you would have called

$myPage = new HAW_deck("FAQ Demo", HAW_ALIGN_CENTER);

the whole deck would have been displayed centered. Every time when there is a predefined value mentioned in the argument list of a function, this value is provided by default as long as you don't supply this parameter explicitely.

So, what we have now is an empty HAW_deck object. Let's bring some content into it: In line 4 a HAW_text object is defined. The reference entry for HAW_text tells you that you have to provide the text (you guessed that, right?) and (optionally) a text format. But to define this object does not automatically make it a part of your HAW_deck object! Therefore you have to call the HAW_deck object's object function add_text(), as done in line 5. Perhaps you ask now why this association is not done automatically, but you will understand it, when you want to re-use HAW_text or HAW_image objects in many positions of your HAW_deck object.

Okay, now we're almost through. We have defined our HAW_deck object and we have filled it with one HAW_text object. Now we only have to make the whole thing visible. Therefore we have to call the HAW_deck object function create_page(). So what we have learned is: For EACH page created by HAWHAW, we have to create ONE HAW_deck object, fill it we some content (like text in this example or images, links etc. as we will see in the succeeding paragraphs), and finally throw it out by calling create_page().

Now point your webbrowser to test.php: What you see is the most simple HAWHAW application ever possible.

0 Comments:

Post a Comment

<< Home