Thursday Nov 15, 2007

[TIP] Sample MIDlet for Mobile Client to WS

NetBeans Mobility Pack provides you a wizard for creating of stubs to connect to a webservice from mobile client. The stubs are generated according the J2ME Web Services Specification - JSR 172. Therefore the client will run only on devices with support for JSR172.

In previous versions of the IDE - 5.0, 5.5, 5.5.1 - the wizard generated even a sample MIDlet that provided a basic usage of the stub. It just took the parameters and showed the return values from the web service. There was lot of restrictions and problems with the sample MIDlet. Therefore the development team decided to drop the feature in NetBeans Mobility 6.0.

The usage of the generated stubs is really easy. IMO, the sample MIDlet might be nice for demo purposes however for the real work it's easier to create the MIDlet from scratch. I'll try to briefly show how to use the generated stubs in visual MIDlet. The sample mobile application is attach. I attached also the web project with the web service.

When you want to use the Java ME Web Service Client wizard you need to have the NetBeans Mobility IDE installed. The wizard isn't part of the standard mobility distribution however you can get it from update center. Look at my post "Where is the End2End functionality of Mobility Pack".
The Java ME Web Service Client wizard generates the stubs for you. You just have to point it to the WSDL file of the web service. You can either provide URL or browse for a wsdl on your hard drive. The wizrd parses and validates the WSDL file. When the web service is WS-I compliant and follows up the JSR 172 restrictions you are able to generate the stubs into a mobile project in the IDE.

When you have the stubs then you just use then in your application. It's very easy. In my case there is only one method public String sayHello(final String name) provided by the web service class HelloWS. The generated stubs class HelloWSService_Stub provides method public String sayHello(String name). Therefore the usage in your mobile application could be
HelloWSService stub = new HelloWSService_Stub(); //create the stub
String result = stub.sayHello("Lukas"); //call the WS method
Look at the attached mobile project how to build up visual MIDlet with Mobile Visual Designer of Mobility Pack. It show the usage of the WaitScreen, Task, and other components provided by the NetBeans Mobility IDE 6.0.

Saturday Aug 18, 2007

[TIP] Using SVG Menu In Visual Designer

The SVG Support in NetBeans Mobility Pack give you new SVG aware components. I already blogged about the SVG support and created a short flash demo.
I'd like to explain how to work with the SVG menu component in this blog entry.

There is SVGMenu component in the palette of Visual Designer in Mobility Pack. You can add SVG Menu Element to the SVGMenu. The SVG Menu Element can be then bind to an element with ID in the SVG image.
	<text id="menuItem_0" ... >
You can do it either manually in Properties of a SVG Menu Element by naming the SVG Menu Element exactly same as the ID or you can follow the SVG Menu Item pattern when creating IDs of the elements in your SVG image. The pattern is "menuItem_NUMBER". When you assign a SVG image with IDs that follow the pattern to the SVGMenu component then the SVG Menu Elements will be created automatically for you. You can watch screencast to see it in action.

SVG Menu Screencast Demo Flash

Tuesday Jul 31, 2007

[TIP] Generate Values to JAD During Build Process

Sometimes you need to modify the build process of your project. There is build.xml file in your project directory that drives the build process. To open it in NetBeans, you have to switch to Files view (at least in Mobility project type). When you open it in the editor you might be surprised that there is only an import of build-impl.xml file and a comment in this file. Yes, the main build targets are defined in build-impl.xml file but you should never modify it because it's a generated file. If you want to add a build target or modify/overwrite an existing one you should do it in the build.xml

You don't have to overwrite the existing targets. There are defined following empty targets that you can define in your build.xml. And they will be run in the right time in your build process.

Defined pre/post targets:
  • pre-init: called before initialization of project properties
  • post-init: called after initialization of project properties
  • pre-preprocess: called before text preprocessing of sources
  • post-preprocess: called after text preprocessing of sources
  • pre-compile: called before source compilation
  • post-compile: called after source compilation
  • pre-obfuscate: called before obfuscation
  • post-obfuscate: called after obfuscation
  • pre-preverify: called before preverification
  • post-preverify: called after preverification
  • pre-jar: called before jar building
  • post-jar: called after jar building
  • pre-clean: called before cleaning build products
  • post-clean: called after cleaning build products

Generate Values to JAD during build process
You need to know what target you want to override, of course. I found out from the build-impl.xml file that the jad is created as part of the jar target. Therefore I will define the post-jar in my build.xml.

Modified build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->>
<project name="" default="jar" basedir=".">
    <description>Builds, tests, and runs the project .</description>
    <import file="nbproject/build-impl.xml"/>
    <target name="post-jar">
        <!-- add all properties that you want to the JAD file -->
        <nb-output file="${dist.dir}/${dist.jad}" encoding="UTF-8" append="true">Lukas_property_1: Blablabla
        <nb-output file="${dist.dir}/${dist.jad}" encoding="UTF-8" append="true">Lukas_property_2: ${name}

Please note that the not-intended </nb-output>. It's by purpose. The nb-output task copies the text as it is to the file.

The jad file will look like :
MIDlet-1: VisualMidlet, , VisualMidlet
MIDlet-Jar-Size: 62157
MIDlet-Jar-URL: MobileApplicationSVG.jar
MIDlet-Name: MobileApplicationSVG
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.1
Lukas_property_1: Blablabla
Lukas_property_2: MobileApplicationSVG 


Monday Feb 05, 2007

Hands on Lab Proposals for Mobility Packs

We posted 3 proposals for hands-on lab (HOL) sessions at JavaOne 2007. I'm really curious if they will accept any of them. The hands-on labs are about Mobility Pack and Java ME development. One of the HOLs is just update of the last year session LAB-6205 Mobile Applications: Visualize it, Build it, Deploy it to Many Devices. The other two are brand new. I'm working on them now. Even if they won't accept them for the session I'll publish them on this blog or at

The Proposals For New HOLs

Title: Advanced Java ME Programming - Streaming Video From Server to Your Device

  • Exercise 1: Play the video on device
    • Objective: Remember audience about MMAPI. The users will develop a mobile application playing a video on device.
    • Expected duration: 30 minutes
    • Brief description: The MMAPI is quite complex set of APIs. The exercise will focus on the APIs necessary for playing a video on a device. Result will be MIDlet that can play a video. This MIDlet will be used in next exercises.
  • Exercise 2: Connect to web service, stream the video from the server
    • Objective: The users will develop a mobile application consuming a web service using J2ME Web Services API (JSR 172). The J2ME Web Services API eliminates the need for developers to include code for remote invocation and XML parsing in each application.
    • Expected duration: 45 minutes
    • Brief description: Communication between the MIDlet and the appserver will be handled by the JSR 172. Application server will provide a webservice that will list available videos. When user will choose one of the videos it will be streamed to the device. We will accommodate the MIDlet created in Exercise 1 to play the video on the device.
  • Exercise 3:
    • Objective: The audience will learn how to solve connecting to webservices on devices without JSR 172 by utilizing device configurations within the IDE. They will generate different distribution packages(JAR/JAD files) using one set of source files for all distributions.
    • Expected duration: 45 minutes
    • Brief description: Attendees will learn how to work with more SDKs/emulator platforms in the Mobility Pack. They will change the project to run on devices with the support for JSR 172 and even on devices without the support for JSR 172. The result will be two different application however they will look the same for the end user of the application. The application will move from two tier architecture (client-server) to three tier architecture in the case when JSR 172 will not be used.

Title: Scale your Java ME world with Java API for SVG

  • Exercise 1: Get in touch the SVG technology in Mobility Pack
    • Objective: Explain the SVG (JSR226) to audience. Show the SVG support in NetBeans Mobility Pack 5.5
    • Expected duration: 20 minutes
    • Brief description: What is SVG (JSR226) about, what is it good for. What SVG components are in the Visual designer. Show SVGImage component. Describe SVGMenu component and its capabilities. How to define flow of the application
  • Exercise 2: Create first application with SVG
    • Objective: Create mobile application that uses the SVG technology. Run it on more phone emulators to show its scalability.
    • Expected duration: 45 minutes
    • Brief description: Create new mobile project. Import SVG images into project resources. Create splash screen with SVG image. Create SVG menu. How to run SVG animation in a screen. Run the application on more phone emulators with different screen size.
  • Exercise 3: Changing the objects on SVG image
    • Objective: Show how the SVG image can be manipulated on the fly. Lets user to manipulate the SVG elements.
    • Expected duration: 40 minutes
    • Brief description: Users will learn manipulate with the svg elements used in the application created in Exercise 2. The result will be a SVG image showing current time. How get the right xml element of the SVG image. How to change the SVG image on fly.
  • Exercise 4: Advanced features
    • Objective: Present features of NetBeans Mobility Pack that will help users when creating a SVG application
    • Expected duration: 20 minutes
    • Brief description: The business logic and the UI is separated in SVG. Therefore it is easy to change the UI of the application. With NetBeans Mobility Pack you can easily change the application for devices that don't support the JSR 226. The IDE can generate PNG image from the SVG images for target devices. It will care about the right width and height of the image automatically. How to easily change the UI of the application. Generate PNGs from the SVG graphics - solution for the phones without JSR 226. Run external SVG editor from IDE.

Any comments/improvements for the proposals are welcome!

UPDATE: They accepted the "Streaming Video From Server to Your Device" hand-on lab. It seems that I'll go to JavaOne this year. Now it's time to write the hands-on lab :)

Tuesday Jan 02, 2007

[TIP] Add Attribute to JAD/Manifest

When you need to add a new attribute to your JAD or manifest file you can set it up in project properties of a project in NetBeans Mobility Pack.

Open "File | YourProject Properties" (or right clict to project and choose "Properties". Then select "Application Descriptor | Attributes". You can add new attributes or edit/remove the existing ones. You can specify whether your attributes will appear in JAD or Manifest (or in both).

You can define different set of attributes for different configurations.

Saturday Dec 02, 2006

Mobility Pack 5.5 for CDC bundles CDC platform

We are going to produce RC1 of NetBeans Mobility Pack 5.5 for CDC next week (hopefully). There is lot of bugfixes in this RC.
There is one more big news. The Sun Java Toolkit for CDC is bundled in the Mobility Pack for CDC installer. It definitelly ioncreased the size of the installer but it will increase usability. Now the Mobility Pack 5.5 for CDC works out-of-box. Just install it and you can start working. Cool.

On the right side is screen shot of the new skin of the CDC Toolkit emulator. Doesn't look cool? (the screenshot was taken on Windows Vista)
The only sad thing about the Sun Java Toolkit for CDC is that it supports only AGUI. It means that if you want develop an Personal Profile application you will have to download another emulator (SDK).

Do you want to try it?

Wednesday Nov 15, 2006

Prague and Java Me Day

Java ME day was first time in Prague. There were other events in the same time just in next doors - OpenSolaris Day, NetBeans Day. Lot of people chose the Java ME. The event went great. Good presenters, interesting topic, giveaways ;)

Adam and Michal created mobile client to web application on the stage. That's pretty impressive. I liked the Petr Suchomel's presentation about SVG. It showed again that he is great presenter. You would believe how he survived problems with a keyboard. He couldn't find hash "#"(it happend when you present on computer from somebody else ;) ). He solved it with creating of preprocessor block and copy+paste. Preprocessor block can be created from contextual menu in editor. The block starts with slash slash hash.

Adam presents the main featurs of Mobility Pack 5.5

Michal demoing. Why is Petr on knees?

Part of WTK team with giveaways (and Sun girls)

First day of Sun Tech Days. The audience.

This is the main channel to share news, tips and other stuff related to my work. Sometimes you can find even personal stuff. Enjoy your reading...


« July 2016

No bookmarks in folder