Mojax is an Ajax application framework for mobile devices.
Traditionally, Ajax developers combine XML, CSS, and Javascript to develop Web applications. Mojax applies AJAX concepts to J2ME MIDP applications for mobile devices. Using mojax, Ajax developers with no mobile programming experience can quickly and easily create mobile applications.
The differences between Mojax applications and Web applications are as follows:
- Mojax applications do not run within a browser.
- They are not subject to the availability and quality of a network connection.
- They have access to lower-level device features such as Camera API, Push Messaging, Bluetooth, Location Services, Contacts and more.
Basic Programming Model
Like Ajax applications, Mojax applications use a combination of XML, Javascript, and CSS. The XML you use can be the specialized MJX tags developed for Mojax, or Javascript.
Layout (MJX)
When you create a Mojax application, you begin by laying out the elements that will appear on the screen. You can specify layout in XML using MJX (mojax XML). Advanced JAVA developers can specify layout using Javascript .
Example: A simple Mojax (MJX) file that renders "Hello World!"
<moblet default="main">
<screen id="main" layout="vertical">
<textbox>Hello World!</textbox>
</screen>
</moblet>
Styling (CSS)
Once you have specified mojax screen elements, you give them visual characteristics (color, padding, and so on) using CSS (Cascading Style Sheets). For a complete reference to CSS support for mojax applications, see CSS Reference.
Example: Adding styles to the Hello World! application using CSS
<moblet default="main">
<style>
screen {
color: #FC0000;
background-color: #CCCCCC;
font-size: medium;
}
</style>
<screen id="main" layout="vertical">
<textbox>Hello World!</textbox>
</screen>
</moblet>
Scripting (Javascript)
Finally, you specify how screen elements respond to user activity. You can script behavior for pre-defined events like onClick or onUpKey.
You specify application behavior using mojax Script, which is identical to Javascript except for object types. The DOM objects you can manipulate via scripting are specific to Mojax applications, and are not based on the HTML document format. For a complete guide to Mojax Script, see Script Language. For a reference to all Mojax Script Objects, see Script Objects.
Example: Adding an "exit()" script call to the "onLeftSoftkey" event handler
<moblet default="main">
<style>
screen {
color: #FC0000;
background-color: #CCCCCC;
font-size: medium;
}
</style>
<screen id="main" layout="vertical" onLeftSoftkey="exit()">
<textbox>Hello World!</textbox>
</screen>
</moblet>