Building Mobile Enterprise Applications : Using webMethods Mobile Designer : Coding a Mobile Application : Mobile Designer-Provided Run-Time Classes : Migration to the New Run-Time based on the _NativeUIDemo_ example : Bind MyCanvas with MyApplication
Bind MyCanvas with MyApplication
1. Add the new private field private MyCanvas canvas into the MyApplication class.
2. Override the init() method.
a. Call super.init() to initialize Mobile Designer default specific bits.
b. Set application listener to receive Application events.
c. Create a new MyCanvas instance.
d. Register MyCanvas to receive all UI events from nUIController by calling nUIController.addEventListener(canvas, false).
3. Forward the information of the new size to the canvas instance in the onSizeChanged method.
4. Override the getMainWindow() method and pass a new main window back.
MyApplication should now look like this :
public class MyApplication extends MDApplication implements
IMDApplicationListener
{
private MyCanvas canvas;

public void init() {
super.init();

// register for application events
setApplicationListener(this);

// create MyCanvas instance
canvas = new MyCanvas();

// register canvas to receive all UI events.
nUIController.addEventListener(canvas, false);
}

public nUIWindowDisplay getMainWindow() {

// return a new main window instance
return canvas.onCreateMainWindow();
}

public void onSizeChanged(int width, int height)
{
// forward to the canvas instance.
canvas.sizeChanged(width, height);
}

/// .... other methods
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback