This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA
Hello /
br/ Hello World!
Click Me here…
Hello /
br/ Hello World!
Click Me here…
Uni Wap Server
Enter the Uni
Choose the info type: <select>
Distributed Objects & Web Services Next Semester.
Internet Programming Currently on.
Internet Programming
Distributed Objects & Web Services
Pervasive Computing & the Enterprise
Work in progress. Please visit later.
Pervasive Computing & the Enterprise Currently on.
*
Uni Wap Services
\|/
-- -
/|\
Uni Wap Services
li " t "
Uni Wap Server "Enter the Uni"
\ | /
--
/ | \
Uni Wap Services
center >
Uni Wap Server <do type="accept" label="Enter the Uni">
Enter Two Numbers to Add
n1:
n2:
Get Results
center > Enter Two Numbers to Add
n1:
n2:
Thanks for using the Add2 Tool
You wanted to add $(n1) and $(n2)
Enter Two Numbers to Add
n1:
n2:
Enter Two Numbers to Add
n1:
n2:
urlA $(urlA) Enter Two Numbers to Add Thanks for using the Add2 Tool Enter the number to call: Enter a number to call:
urlB $(urlB)
urlA:n $(urlA:n)
urlB:n h f "$( lB )" lB $(urlB:n)
$( lB ) / b/ urlA:u $(urlA:u)
urlB:u $(urlB:u)
urlA:e $(urlA:e)
urlB:e $(urlB:e)
Referencing Variables
The University of Auckland
The University of Auckland
New Zealand
Referencing Variables
Referencing Variables
$(urlA)
file nameA.wml
$(urlB)
file%20nameB.wml
$(urlA:n)
file nameA.wml
$(urlB:n)
file%20nameB.wml
$(urlA:u)
file nameA.wml
$(urlB:u)
file nameB.wml
$(urlA:e)
file%20nameA.wml
$(urlB:e)
file%2520nameB.wml
WML Example #5
Reference within a URL
© Manoharan
D k Deck
file%20nameA.wml file%2520nameB.wml
$(urlA:n)
file%20nameA.wml
$(urlB:n)
file%20nameB.wml
$(urlA:u)
file%20nameA.wml
$(urlB:u)
file%20nameB.wml
$(urlA:e)
file%20nameA.wml
$(urlB:e)
file%2520nameB.wml
InputNumbers New Zealand
$(urlB)
The University of Auckland
The University of Auckland
New Zealand
$(urlA)
Result
InputNumbers asks for two numbers, and Result displays the sum
9
COMPSCI 734
April 7, 2008
New Zealand
n1:
n2:
WML Example #5: Result
The University of Auckland
The University of Auckland
New Zealand
WML Example #5: InputNumbers
© Manoharan
New Zealand
extern function add2() { var n1 = Lang.parseInt(WMLBrowser.getVar("n1")); var n2 = Lang.parseInt(WMLBrowser.getVar("n2")); var sum = n1 + n2; var sumStr = String.format("%d", sum); WMLBrowser.setVar("reslt", WMLBrowser.setVar( reslt , sumStr); WMLBrowser.go( "add2.wml#Result" ); }
WMLS Example #6
The University of Auckland
The University of Auckland
New Zealand
WMLS Example #5
You wanted to add $(n1) and $(n2)
The result you require is $(reslt)
extern function add2() { var n1 = Lang.parseInt(WMLBrowser.getVar("n1")); var n2 = Lang.parseInt(WMLBrowser.getVar("n2")); var sum = n1 + n2; var sumStr = String.format("%d", sum); Dialogs alert("The res Dialogs.alert("The result lt is is: " + ssumStr); mStr) }
10
COMPSCI 734
April 7, 2008
WML Script
WML Script Libraries
Lang
Literals can be of the following types: boolean, integer, string, floating point, and invalids
Lang library includes functions for data type manipulations, absolute value l calculations, l l ti general-purpose l math th ffunctionality, ti lit and d random d number generation
WML Script Libraries
Dialogs.alert(“The parameter is: “ + parameter);
Dialogs.confirm(text, ok, cancel)
© Manoharan
New Zealand
Dialogs.confirm(“The parameter is: “ + parameter, “OK”, “NOTOK”);
Dialogs.prompt(text, default) Dialogs.prompt(“Who are you?”, “James Bond”);
The University of Auckland
The University of Auckland
New Zealand
Browser
Provides a set of typical user-interface functions such as prompt(), confirm(), and alert()
The String library contains methods such as length(), charAt(), find(), etc. etc
Dialogs.alert(text)
The URL library contains functions such as getPath(), getReferer(), getHost(), etc.
Dialog
String
The Dialogs Library
URL
WML browser interface Provides interaction with the browser
Optional Float library includes functions such as pow(), round(), etc, but only supported on devices with floating point capabilities
The University of Auckland
New Zealand The University of Auckland
d = myFloat / 0; if ( d == invalid ) { // divide by zero error }
New Zealand
Float
var mString = “hello world”; var myInteger = 34; var myFloat = 3.142; var d;
11
COMPSCI 734
April 7, 2008
New Zealand
Standard Library Functions
Basic String Manipulation
Basic String Manipulation
String.substring(string, position, length); String.find(string, substring);
White Space New Zealand
String.isEmpty(string) String.length(string) String.charAt(string, position)
Substrings
String.squeeze() String.trim()
The University of Auckland
The University of Auckland
New Zealand
The String library offers all manner of functionality for handling and processing strings. Example
© Manoharan
Lang.random(parameter) Lang.maxInt() g () Lang.minInt() Float.maxFloat() Float.minFloat() Float.pow(number, power); Float.sqrt()
The University of Auckland
Lang.max(myVal1, myVal2); Lang.min(myVal1, g ( y , myVal2); y ); Lang.abs(myVal) Float.int(myVal) Float.floor(myVal) Float.ceil(myVal) Float.round(myVal)
The University of Auckland
New Zealand
Standard Library Functions
12
COMPSCI 734
April 7, 2008
String Formatting
Strings as Arrays
String.format(template, value);
Standard Library String-Access Fuctions
The formatting template is similar to the format specification used in C’s printf.
New Zealand The University of Auckland
The University of Auckland
New Zealand
• d for integer • f for float • s for string
WTAI
WTAI
Wireless Telephony Application Interface is a means to create telephony applications using a WTA user-agent with appropriate libraries
WTAI includes:
Not all phones support WTAI. Check if your phone does!
New Zealand
Calling a number through URL reference wtai://wp/mc;777
Call control Network text messaging Phone book interface Indicator control Event processing
WTAI available in WML and WML Script
The University of Auckland
The University of Auckland
New Zealand
Calling a number using WML Script WTAPublic.makeCall("777");
© Manoharan
string.elements() string.elementAt() string.removeAt() string.replaceAt() string.insertAt()
13
COMPSCI 734
April 7, 2008
Sample Application #1
Sample Application #1 (2)
New Zealand
Sample Application #2
WTAI
Other useful WTAI functions include WTAPublic.addPBEntry, WTAPublic.sendDTMF, WTAPhoneBook.write, and WTAPhoneBook.search. Refer to the specification for details.
© Manoharan
New Zealand The University of Auckland
The University of Auckland
New Zealand
<wml>
extern t function f ti dial() di l() { var n1 = Lang.parseInt(WMLBrowser.getVar("n")); WTAPublic.makeCall(n1); }
The University of Auckland
The University of Auckland
New Zealand
<wml>
14
COMPSCI 734
April 7, 2008
Limits
Limits
There is a limit on the maximum compiled deck size, and this varies from device to device
The history buffer is also limited. Explicit “back” links may be required rather than relying on the history buffer to go back. E.g., Alcatel 525 has a history buffer of size 10. New Zealand
The maximum size of a WBMP image too is limited.
Write a WML application for English dictionary lookup. Use a web service for the actual dictionary lookup.
Write an MCQ Testing suite using WML. Use questions from COMPSCI 334-35 as sample data. New Zealand
Wireless Markup Language Specification. www.WAPForum.org. WML Script Specification. WML Script Standard Libraries Specification. WAP Wireless Telephony Application Interface.
Exercises
The University of Auckland
The University of Auckland
New Zealand
Further Reading
© Manoharan
E.g., Alcatel 525 has a limit of 784 bytes.
The University of Auckland
The University of Auckland
New Zealand
Nokia 7110’s is 1397 bytes while Alcatel 525’s is 6656 bytes
The contents will not be loaded, if the maximum size is exceeded. Maximum number of cards within a deck and the maximum size of a card are bounded by the maximum size of the deck.
15
COMPSCI 734
April 7, 2008
Exercises
The University of Auckland
New Zealand
Find out an approximate maximum deck size supported a mobile phone of your choice. Describe the card-and-deck metaphor used by WML applications, and discuss why such a metaphor is chosen.
© Manoharan
16