Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 23 - Wireless Internet and m-Business

Similar presentations


Presentation on theme: "Chapter 23 - Wireless Internet and m-Business"— Presentation transcript:

1 Chapter 23 - Wireless Internet and m-Business
Outline Introduction M-Business Identifying User Location E911 Act Location-Identification Technologies Wireless Marketing, Advertising and Promotions Wireless Payment Options Privacy and the Wireless Internet International Wireless Communications Wireless-Communications Technologies WAP and WML Phone Simulator and Setup Instructions Creating WML Documents WMLScript Programming String Object Methods

2 Chapter 23 - Wireless Internet and m-Business
Outline Wireless Protocols, Platforms and Programming Languages WAP 2.0 Handheld Devices Markup Languages (HDML) Compact HTML (cHTML) and i-mode Java and Java 2 Micro Edition (J2ME) Binary Run-Time Environment for Wireless (BREW) Bluetooth Wireless Technology Internet and World Wide Web Resources

3 23.4 Wireless Marketing, Advertising and Promotions

4 This text will be displayed in the browser window.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig. 23.2: fig23_2.wml --> 6 <!-- Simple WML Page > 7 8 <wml> 9 <card id = "index" title = "WML Title"> <p> Welcome to wireless programming! </p> 13 </card> 14 </wml> Fig23_2.wml This text will be displayed in the browser window.

5 Program Output

6 Program Output

7 23.11 Creating WML Documents
List of errors in deck. Fig Phone Information window showing an error in the deck.

8 The text Link is a link to card2.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig. 23.4: fig23_4.wml --> 6 <!-- Using local icons > 7 8 <wml> 9 <card id = "index" title = "Icons"> <p> Local Icons<br /> 12 <!-- link to the second card --> <a href = "#card2"> 15 <!-- insert the local icon --> <img src = "" alt = "Link" localsrc = "link" /> </a>Link<br /> 19 <!-- link to the third card --> <a href = "#card3"> <img src = "" alt = "Wrench" localsrc = "wrench" /> </a>Wrench<br /> 24 <!--link to an external card--> <a href = "fig23_5.wml#card4"> <img src = "" alt = "Football" localsrc = "football" /> </a>Football<br /> 29 <a href = "fig23_5.wml#card5"> <img src = "" alt = "Boat" localsrc = "boat" /> </a>Boat </p> 34 </card> Fig23_4.wml The text Link is a link to card2. The text Wrench is a link to card3. The text Football is a link to card4 in fig23_5.wml. The boat local icon is a link to card5 in fig23_5.wml.

9 Result of choosing the link icon.
35 36 <card id = "card2" title = "Icons"> <p> You chose the link! </p> 40 </card> 41 42 <card id = "card3" title = "Wrench Link"> <p> You chose the wrench! </p> 46 </card> 47 </wml> Fig23_4.wml Result of choosing the link icon. Result of choosing the wrench icon.

10 Result of choosing the football link.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig. 23.5: fig23_5.wml > 6 <!-- Linking to an external card --> 7 8 <wml> 9 <card id = "card4" title = "Football Link"> <p> You chose the football! </p> 13 </card> 14 15 <card id = "card5" title = "Boat Link"> <p> You chose the boat! </p> 19 </card> 20 </wml> Fig23_5.wml Result of choosing the football link. Result choosing the boat link.

11 Program Output

12 Method refresh refreshes the browser and all variable values.
1 // Fig. 23.6: welcomeDoc.wmls 2 // Writing a line of text 3 4 extern function welcome() 5 { 6 // creating a browser variable and assigning it a value 7 WMLBrowser.setVar( "welcome", "Welcome to WMLScript programming!" ); 9 10 // refresh the display window 11 WMLBrowser.refresh(); 12 } WelcomeDoc.wmls Method setVar creates a browser variable welcome with the value of the string “Welcome to WMLScript programming”. Method refresh refreshes the browser and all variable values.

13 Dereferencing browser variable welcome displays its value.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig. 23.7: fig23_7.wml --> 6 <!-- Printing a line of text --> 7 8 <wml> 9 <card id = "Line" title = "Line"> 10 <onevent type = "onenterforward"> 12 <!-- call function welcome --> <go href = "welcomeDoc.wmls#welcome()" /> 15 </onevent> 17 <p> $welcome <!-- dereference browser variable welcome --> </p> 21 </card> 22 </wml> Fig23_7.wml Dereferencing browser variable welcome displays its value.

14 Program Output

15 The alert method displays the string passed to it in a dialog box.
1 // Fig. 23.8: dialogPrompt.wmls 2 // Printing multiple lines in a dialog 3 4 extern function displayDialog() 5 { 6 Dialogs.alert( "Welcome to\nWMLScript\nProgramming!" ); 7 } DialogPrompt.wmls The alert method displays the string passed to it in a dialog box. Each line break character places the remaining text on the next line in the browser.

16 When the cars is entered, function displayDialog will be called.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig. 23.9: fig23_9.wml --> 6 <!-- Using dialogs > 7 8 <wml> 9 <card id = "Dialog" title = "Dialog"> 10 <!-- event element to execute go element --> <onevent type = "onenterforward"> 13 <!-- call function displayDialog --> <!-- in dialogPrompt.wmls > <go href = "dialogPrompt.wmls#displayDialog()" /> 17 </onevent> 19 20 </card> 21 </wml> Setting the type attribute to onenterforward causes the action of the go element to be executed when the card is entered. Fig23_9.wml When the cars is entered, function displayDialog will be called.

17 Program Output

18 Call function square and pass it the value input by the user.
1 // Fig : squareNumbers.wmls 2 // Programmer-defined functions 3 4 extern function count() 5 { 6 // prompt the user for a number 7 var inputNumber = Dialogs.prompt( "Enter a number to be squared", "" ); 9 10 // convert the number to an integer and pass 11 // the number to function square 12 var numberSquared = square( Lang.parseInt( inputNumber ) ); 13 14 var outputSquare = inputNumber + " squared is " + numberSquared; 16 17 // set the string to a browser variable and 18 // redirect the client to the card named result 19 WMLBrowser.setVar( "result1", outputSquare ); 20 WMLBrowser.go( "#result" ); 21 } 22 23 function square( y ) 24 { 25 return y * y; 26 } SquareNumbers.wmls Method prompt displays a dialog box that displays a message and an input field. The second argument passed to methos prompt is the default value for the input field The first argument passed to method prompt is the message that is displayed in the dialog. Call function square and pass it the value input by the user. Variable y gets the value of inputNumber.

19 This soft key calls function count when pressed.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig : fig23_11.wml --> 6 <!-- Squaring numbers > 7 8 <wml> 9 <card id = "index" title = "Number Squared"> 10 <!-- soft key to invoke function count --> <do type = "accept" label = "OK"> <go href = "squareNumbers.wmls#count()" /> </do> 15 <p> Press OK to square a number. </p> 19 </card> 20 21 <card id = "result" title = "Results"> 22 <!-- soft key that returns the user to the previous card-> <do type = "accept" label = "Home"> <prev /> </do> 27 <p> $result1 </p> 31 </card> 32 </wml> Fig23_11.wml This soft key calls function count when pressed. Dereferencing variable result displays the result of the calculation. The prev element sends the client back to the previous card.

20 Program Output

21 Method getVar retrieves the value of browser variable username.
1 // Fig : getVariable.wmls 2 // Using the WMLBrowser object’s getVar method 3 4 extern function getName() 5 { 6 var x = WMLBrowser.getVar( "username" ); 7 var y = x + ", thanks for visiting!"; 8 9 WMLBrowser.setVar( "result", y ); 10 WMLBrowser.go( "#card2" ); 11 } GetVariable.wmls Method getVar retrieves the value of browser variable username. The + operator concatenates the value of x and the string “, thanks for visiting”.

22 This soft key calls function getName when pressed.
1 <?xml version = "1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig : getVar.wml > 6 <!-- Using the WMLBrowser object’s getVar method --> 7 8 <wml> 9 <card id = "index" title = "getVar"> <do type = "accept" label = "Run"> 11 <!-- call function getName --> <go href = "getVariable.wmls#getName()" /> 14 </do> 16 <p> Enter your name:<br /> 19 <!-- create input box for user input --> <input name = "username" value = "" /> 22 </p> 24 </card> 25 26 <card id = "card2" title = "getVar"> 27 <!-- create a soft key to return the client --> <!-- to the previous card > <do type = "accept" label = "Back"> <prev /> </do> 33 GetVar.wml This soft key calls function getName when pressed. This input field allows the user to enter a username. This soft key sends the client to the previous card.

23 GetVar.wml Program Output
$result <!-- dereference browser variable result --> </p> 37 </card> 38 </wml> Dereferencing browser variable result displays the results of the script. GetVar.wml Program Output

24 The value of variable string1 begins as an empty string.
1 // Fig : functionSet.wmls 2 // Demonstrating String object methods 3 4 extern function stringMethods() 5 { 6 var string1 = ""; 7 var empty; 8 9 // test if string1 is empty 10 if ( String.isEmpty( string1 ) ) empty = "string1 is empty"; 12 else empty = "string1 is not empty"; 14 15 WMLBrowser.setVar( "emptyString1", empty ); 16 17 // format the string to have 12 spaces between 18 // "Wireless" and "Web" 19 string1 = String.format( "Wireless%15s", "Web" ); 20 21 WMLBrowser.setVar( "formatString1", string1 ); 22 23 // squeeze the string until one space is left 24 string1 = String.squeeze( string1 ); 25 26 WMLBrowser.setVar( "squeezeString1", string1 ); 27 28 // use method element to count the elements in string1 29 // use the toString method to convert the integer to 30 // a string 31 var count = String.toString( String.elements( string1, " ") ); 32 33 WMLBrowser.setVar( "elementsString1", count ); 34 Method isEmpty determines if the string is empty and returns true if it is. FunctionSet.wmls The value of variable string1 begins as an empty string. After invoking the format method, the value of string1 will be “Wireless Web” with 12 spaces separating the two words. Method squeeze eliminates all consecutive whitespace leaving one space between Wireless and Web. Method elements determines the amount of elements in a string separated by a space (the second argument). Method toString converts the integer value returns by method elements to a string.

25 35 // find string starting at index 8 and ending with a space
36 var string1Element = String.elementAt( string1, 8, " " ); 37 38 WMLBrowser.setVar( "elementAtString1", string1Element ); 39 40 // get the length of string1 41 var length = String.length( string1 ); 42 43 // insert "Book" at the end of string1 44 string1 = String.insertAt( string1, "Book", length, " " ); 45 46 WMLBrowser.setVar( "insertAtString1", string1 ); 47 48 // replace "Web" with "Deitel" where "Web" has an 49 // index of 1 50 string1 = String.replaceAt( string1, "Deitel", 1, " " ); 51 52 WMLBrowser.setVar( "replaceAtString1", string1 ); 53 54 // remove "Wireless" from string1 55 string1 = String.removeAt( string1, 0, " " ); 56 57 WMLBrowser.setVar( "removeAtString1", string1 ); 58 WMLBrowser.go( "#card2" ); 59 } Method elementAt will return a substring from the value of string1 starting at index 8 and ending at a space. Method replaceAt removes “Web” from string1 and replaces it with the string “Deitel” (Wireless Deitel Book). FunctionSet.wmls Method length returns the number of characters in string1 as an integer. Method insertAt inserts the string “Book” at the end of the value of string1 (Wireless Web Book). Method removeAt removes the string “Wireless” from the value of string1 leaving “Deitel Book”.

26 StringMisc.wml 1 <?xml version = "1.0"?>
2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 " 4 5 <!-- Fig : stringMisc.wml > 6 <!-- WML document that references stringMisc.wmls --> 7 8 <wml> 9 10 <card id = "index" title = "strings"> <do type = "accept" label = "Run"> 12 <!-- call function stringMethods in functionSet.wmls --> <go href = "functionSet.wmls#stringMethods()" /> 15 </do> 17 <p> Click Run to execute the script. </p> 21 </card> 22 23 <card id ="card2" title = "strings"> <do type = "accept" label = "Run"> 25 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card3" /> 29 </do> 31 StringMisc.wml

27 Display results of invoking method isEmpty.
isEmpty method:<br /> 34 <!-- dereference browser variable emptyString1 --> $emptyString1 37 </p> 39 </card> 40 41 <card id = "card3" title = "strings"> <do type = "accept" label = "Run"> 43 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card4" /> 47 </do> 49 <p> String.format method:<br /> 52 <!-- dereference browser variable formatString1 --> $formatString1 </p> 56 </card> 57 58 <card id = "card4" title = "strings"> <do type = "accept" label = "Run"> 60 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card5" /> </do> 65 StringMisc.wml Display results of invoking method isEmpty. Display result of invoking method format.

28 Display results of invoking method squeeze.
String.squeeze method:<br /> 68 <!-- dereference browser variable squeezeString1 --> $squeezeString1 </p> 72 73 </card> 74 75 <card id = "card5" title = "strings"> <do type = "accept" label = "Run"> 77 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card6" /> </do> 82 <p> String.elements method:<br /> 85 <!-- dereference browser variable elementsString1 --> $elementsString1 </p> 89 </card> 90 91 <card id = "card6" title = "strings"> <do type = "accept" label = "Run"> 93 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card7" /> </do> 98 StringMisc.wml Display results of invoking method squeeze. Display result of invoking method elements.

29 Display results of invoking method elementAt.
String.elementAt method:<br /> 101 <!-- dereference browser variable elementAtString1 --> $elementAtString1 </p> </card> 106 <card id = "card7" title = "strings"> <do type = "accept" label = "Run"> 109 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card8" /> </do> 114 <p> String.insertAt method:<br /> 117 <!-- dereference browser variable insertAtString1 --> $insertAtString1 </p> </card> 122 <card id = "card8" title = "strings"> <do type = "accept" label = "Run"> 125 <!-- redirect the user to the next card to --> <!-- display further results > <go href = "#card9" /> </do> 130 StringMisc.wml Display results of invoking method elementAt. Display result of invoking method insertAt.

30 Display results of invoking method replaceAt.
String.replaceAt method:<br /> 133 <!-- dereference browser variable replaceAtString1 --> $replaceAtString1 </p> </card> 138 <card id = "card9" title = "strings"> <do type = "accept" label = "Home"> 141 <!-- redirect the user to the first card --> <go href = "#index" /> </do> 145 <p> String.removeAt method:<br /> 148 <!-- dereference browser variable removeAtString1 --> $removeAtString1 </p> </card> 153 </wml> StringMisc.wml Display results of invoking method replaceAt. Display result of invoking method removeAt.

31 Program Output

32 Program Output


Download ppt "Chapter 23 - Wireless Internet and m-Business"

Similar presentations


Ads by Google