Show TOC

Applying Controller TemplatesLocate this document in the navigation structure

Prerequisites

You have created:

  • A Mobile Service Component with at least one service operation

  • A Mobile UI Component that has a dependency to the Mobile Service Component

  • A WD component

Context

Mobile Applications for Handhelds provide a dedicated generation template to accelerate and simplify the UI development process in the Composite Development Scenario. When applied to a component controller, the template automatically creates:

  • A Web Dynpro (WD) model of type Mobile Service Component Model

  • The controller context with a structure that is identical to the referenced Mobile Service Component's service operations.

    The context nodes are bound to the respective WD model classes. Input and output structures of the service operations appear as context attributes.

  • Supply functions that perform the model binding between the WD model and controller context

  • Convenience methods within the controller that have the same name as the service operations

    These methods can, for example, be used to bind a button directly to a query, which is then executed when the button is pressed.

After applying the controller template, you own all generated code and model entities and can change them whenever required.

You can adapt the generated code to your specific requirements. You can add new operations and reapply the template. On reapplying the template, your coding changes are preserved, since only new or previously unselected service operations are added when the template is reapplied. However, no coding is replaced.

Recommendation

We recommend that you apply the template to the component controller and that you create the view controller context through mapping of the component controller context, although the template can also be applied to view controllers.

Two method types are generated:

  • <name of service operation> ) reads the arguments of the service operations from its input parameters

  • execute <name of service operation> reads the input parameters from the context

If you reapply a template to the UI component controller, only the service operations that were not checked before are shown. This allows you to add new service operations to your Mobile Service Component and to build your UI controller context incrementally from these.

Alternatively, you can develop the component controller and Web Dynpro (WD) model using standard WD concepts and tools, that means modeling the component context, adding custom code to the controller, creating the WD model, and so forth.

In your code, you have full access to the service provided by the runtime API of the Mobile Client for Handhelds as well as to standard Java runtime API provided by Java 2 Micro Edition (J2ME).

More information: API Overview

Procedure


  1. In the Handhelds UI Explorer, open the Component Controller context menu and choose Start of the navigation path Template  Next navigation step Apply End of the navigation path.

  2. In the Apply Template dialog box, choose the Mobile Service Component template.

  3. In the next dialog box, choose whether to bind the generated context to an existing WD model of type Mobile Service Component or to a new one.

    If you want to bind the context to an existing model, select the model from the dropdown list. If you want to create a new model, choose New and, in the subsequent dialog box, enter a name for the model.

  4. In the Select Service dialog box, choose the services you want to map to the component controller context.

  5. In the Select Entities dialog box, select the required service operations.

    If the template was already applied, only the service operations that were not already mapped are shown.

Results

The component controller context, model (if requested), supply functions, and convenience methods are generated.