Mobile message board example for NetBeans 5.0

Introduction

The Net Caboodle platform makes it quick and easy to write and deploy mobile applications that access your business services.

This example uses a simple POJO (Plan Old Java Object) service that allows MIDP clients to post and read messages on a simple message board via the Internet and the Net Caboodle gateway

Download Code Example

To use this example you need

 

Getting started

Download the example project ZIP file, extract it and then open the two projects in NetBeans as shown below.

Start the Net Caboodle Gateway

Having opened both the Message Board Bean and MIDPMessage client projects in NetBeans, the next step is to start the Net Caboodle Gateway as shown below.

You can check that the Gateway has started correctly by looking at the Net Caboodle: console

Creating the MIDP stubs

To allow the mobile client to communicate with the Message Board Bean, you need to generate the mobile stubs.

Select the MIDP project and the use the "Tools | Net Caboodle Business 2 Mobile | New connector..." menu option.

Having selected the above menu option you will presented with the "New Connector" dialog as shown below.

  • Select the "Bean connector" tab
  • Use the browser button and select the "Message_board_bean.jar" from the "dist" sub-directory of the Message Board Bean project directory.
  • Select the class "com.nc.example.MessageBoardBean" from the classes list
  • Click OK to generate the mobile stubs
  • Check the Gateway console for any errors.

Testing the Mobile client

If you have successfully followed the steps above, you can now try out the mobile client, by right-clicking on the MIDP project and selecting "Run Project"

Using the emulator

NetBeans will now start-up the MIDP emulator as shown below. Select the application and you will be prompted "Is it OK to use airtime?"

If you are wondering why the emulator is prompting you with this question, it is because it is emulating what happens on a real device.

There's no need to worry about this with the emulator, the only connection being made is to the Gateway running in NetBeans on your local computer.

The mobile application has two menu options and a ticker across the top.

Select "Yes"

1: Select "Post message" by pressing the select key on the emulator

 

2: Enter a nickname and a message to post to the message board, then select "Send"

3: Your message will appear in the ticker and the Message text field will be cleared

4: Use the "Back" button to return to the main menu and select "Read messages"

Having tested the example with one emulator, leave the emulator running and run up an second instance from NetBeans, this will allow you to experiment with multiple users.

Running the example on your phone or device

To be able run this example on your phone or device you need to have the following

1. PC connected to the Internet

2. Open port 8205 on your personal firewall

3. Modify the MIDP clients JAD file with the following properties, where gatewayHost is the Internet IP Address of your computer. To set these properties, right-click on the MIDP project and select "Properties"

4. Rebuild the MIDP project

5. Transfer the JAD and JAD files to your phone or device - these can be found in the "dist" sub-directory of the project.

For more information about using Net Caboodle please contact contact us

Related documents

File sharing example
In this simple example we are going to take a look at how to write a simple POJO (Plan Old Java Object) service that allows MIDP clients to store data remotely for either personal or public consumption -- you can think of this example like an Internet file sharing service for Mobile devices.

Database connector Example
In this article (which include a source code download) we explain how to create a mobile (MIDP) messaging client that reads and stores messages in a relational database.

Site Engineer Example
This example explains how to create a mobile application that allows service engineers in the field to access and order the equipment and parts they need to repair applicances.

Summary

The code provided with this example shows how to use a very basic POJO (Plain Old Java Object) as an internet service for your mobile applications to interact with.

The Net Caboodle plugin for NetBeans generates all the code your mobile client needs to communicate with your services running OTA (over the air) - all communication between the mobile client and the gateway is encrypted.

Support and Feedback

If you have any questions relating to this article please contact us

 

Copyright notice

The information within this document remains the sole property of Net Caboodle - www.netcaboodle.com

No part of this document may be copied or reproduced in any form or by any means, and the information
contained within it is not to be communicated to a third party, without the prior written consent of
Net Caboodle. All trademarks remain the property of their respective owners. NetCaboodle, Caboodle server
and Raven are all trademarks of Net Caboodle.