|
Asking user inputYou can easily make an item editable by specifying a type="text" attribute. You can also add a label attribute which is displayed before the user entered any text.<?xml version="1.0"?>
<max id="mycompany.sample4" version="1.0">
<page id="default">
<title>Sample 4</title>
<item type="text" label="Enter your name" />
</page>
<max>
Initially the page will display an item with the label : Enter your name. When the
user selects this item and presses the center key of the mobile phone, a popup input
box will be displayed. When he has finished entering text, the item in
the page will be updated to display the text he just entered.
Multiple pages and navigationYou can add multiple pages in your application to create a complex behavior and navigate between these pages using urls, just like you would do with a web site. <?xml version="1.0"?>
<max id="mycompany.sample5" version="1.0">
<page id="page1">
<title>This is page 1</title>
<item href="page2">Go to page 2</item>
<item href="page3">Go to page 3</item>
</page>
You already noticed that each page node contains an id attribute which uniquely identfies the page within the application. Passing Parameters between pagesYou can pass any parameter in the target page url, the same way you would do with standard web sites and html pages. These parameters can be retrieved using the request object in the target page. <?xml version="1.0"?>
<max id="mycompany.sample6" version="1.0">
<page id="page1">
<title>What's your name?</title>
<item href="page2?name=Bill">I'm Bill</item>
<item href="page2?name=Steve">I'm Steve</item>
</page>
<page id="page2">
<title>Your name is:</title>
<item>{request.name}</item>
</page>
</max>
In this example, we are passing the parameter name and its value to page2. In page2, we retrieve this parameter using {request.name} and display it Defining a Data StoreThe Upvise client contains an embedded database and you can easily define any number of tables (called data sources) to enable local persistence of data on the phone. Supported data types are
To define a data source in a max application, use the datasrc tag. You must specificy a mandatory id attribute which is the datasource name. Then you define the fields with the field tag. You can have up to 255 fields in a datasource. Each field tag must contain a type attribute corresponding to one of the value above. <?xml version="1.0"?> <max id="mycompany.sample7" version="1.0"> <datasrc id="customers"> QueriesIn any page on the MAX application, you can define queries against a local data source. Queries can be of type: select, insert, update, delete and updatemultiple
Use the following URL like syntax:
Databinding
Once you defined a SELECT query in a given MAX page, you can easily bind the values
of the resulting recordset into any MAX UI tag, Simply use the {queryid.fieldid}
syntax in any tag content or attribute. queryid is the id of the
query you defined in the same MAX page and fieldid is the name
of a field of the datasource used in the query. <?xml version="1.0"?>
<max id="mycompany.sample6" version="1.0">
...
<page id="view">
<query id="data" type="select">customers?id=5</query>
<title>Customer Detail</title>
<item label="Name">{data.name}</item>
<item label="Company">{data.company}</item>
<item label="Importance">{data.importance}</item>
<item label="Date">{data.creationdate.date}</item>
</page>
...
</max>
Posting Data to a serverYou can easily post data gathered from user input using a GET or POST query. To
do so, simply define a custom query of type "sendget" to send data
using HTTP GET or "sendpost" using HTTP POST. The target server
URL and the parameters are set on the text content of the query parameter. Note
that the URL must be an absolute http URL. <query id="myquery" type="sendget">http://myserver?name=Bill&age=32</query> You can call this custom query with the standard [queryid].execute() script from any onclick attribute. A simple example is given below: <?xml version="1.0"?>
<max id="mycompany.sample7" version="1.0">
<title>Post Data</title>
<page id="default">
<query id="mywebservice" type="sendget">http://myserver?name=Bill&age=32</query>
<title>Post Data</title>
<item onclick="mywebservice.execute()">SEND NOW</item>
</page>
</max>
Warning: you need to be in Online mode on your mobile phone to issue any send or post request. If you are in Offline mode, the request will not be sent until you go into Online mode (it will stay on the Outbox HTTP query cache on the phone). This applies both to real phones and the simulator. Adding some scriptingcoming soon... |
