The project name used within Worklight Studio is HelloWorld
, and the display name of the app will be HelloWorld, as defined earlier in step 4 of the Creating a simple IBM Worklight application section. To change the name, follow the steps defined as follows:
application-descriptor.xml
file in Project Explorer to open in Application Descriptor Editor.HelloWorld
to any other name of your choice.You can also change the description by editing the Description attribute.
application-descriptor.xml
file.Now, let's move on to the structure of the application. The default environment is called the common environment. It is responsible for holding every component and file related to the app, which shares its resources with the environment.
In order to run the Worklight app on multiple devices, you must have the following resource files in your project. IBM Worklight automatically generates any missing resources that are not supplied. These resources are inter-related with each other.
HelloWorld.html
: This is the main HTML file that acts as the interface of the mobile application. This file loads all the web resources (script and style sheets) necessary to define the general components of the application and to hook required document events. By default, this file is placed under the common
folder.css
: This folder extends or overrides both common files to keep the structure in the framework. It consists of the following files:HelloWorld.css
: This is the main CSS fileReset.css
: This file brings all rendering-oriented engines to a common groundimages
: This folder contains images for separate image locations to be called in HTML, directly or using CSS.js
: This folder extends the application instance object and common app class. It contains some predefined files:HelloWorld.js
: This is the main application JavaScript file.Message.js
: This JavaScript file holds JSON objects that contain app messages. It can be used as a source for localization translation.application-descriptor.xml
: This file holds application metadata. Its attributes will be discussed during deployment of this application later in this chapter.In the following screenshot, we highlight the project application structure and resources:
If you proceed with the hybrid application wizard you will have server-side configuration under the following folders structure:
bin
: This folder contains generated .wlapp
and .wladapter
files that can be used to deploy to a remote Worklight server.server
: This folder is used for server-side customization of a project.Conf
: This folder contains a file called worklight.properties
, used to set up properties for the serverauthenticationConfig.xml
: This file is used to set authentication realmslogin.html
: This file is used to present a login form for web environments and Worklight Consolejava
: This folder holds Java classes that will be compiled and deployed to IBM Worklight Server for handling customized Java code-based application.lib
: This folder contains some additional JAR files that can be used to extend Java class functionalities and can be deployed on the server. You can see the folder structure of the bin
and server
folders in the following screenshot:Now put in some additional code to provide a better display to your mobile application:
HelloWorld/common/css/HelloWorld.css
and add the following lines to define style:/* HelloWorld CSS */ #AppBody { height: 460px; margin: 0 auto; width: 320px; background-color: #ccc; overflow: hidden; overflow-y: auto; } #header { text-align: center; background-color: #1D4D90; color: #F9FAFB; font-size: 16px; height: 38px; line-height: 38px; border-bottom: 1px solid #BBBBBB; } #wrapper { padding: 10px; }
Downloading the example code
You can download the example code files for all Packt books you have purchased through your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
HelloWorld.html
in the app/common
folder. When you open this file, you'll find generated code with referenced script and CSS files within the same with <body>
tag.Note that the <body>
tag must have the ID
attribute value set to the content
. If you change the value, the application environment does not initialize correctly.
<body>
tag:<div id="AppBody"> <div id="header"> <div id="wrapper"> Welcome </div> </div> Hello World </div>
Now our HelloWorld application is done. You can preview our first designed page in Rich Page Editor (RPE) provided by IDE.
3.15.229.111