Creating a composite viewAdded by IBM on October 4, 2010 | Version 1 (Original)
|Once you have defined a mobile composite application, you must create a composite view that will be hosted in the application.
Once you have defined a mobile composite application, you must create a composite view that will be hosted in the application.
To create a composite view, complete the following steps.
- Create a new class that extends com.ibm.ercp.compositeframework.ui.view.CompositeView; for example, SampleClientsView. Be sure to check the checkbox for creating method stubs for constructors in the class creation wizard.
- This class is responsible for instantiating the appropriate eSWT widgets for actually displaying the user interface elements to the user. There are several methods that must be implemented in this class:
Create a new class that extends com.ibm.ercp.compositeframework.ui.view.CompositeViewProvider; for example, SampleClientsViewProvider. Be sure to select the checkbox for creating method stubs for constructors in the class creation wizard.
This class is responsible for providing instances of composite views. Instances of this class are created by the framework and live for the lifetime of the application.
- getLabel(). This is a friendly label for the composite view; for example, My Clients.
- getIdentifier(). This is used by the framework for uniquely identifying this composite view; for example, my.clients.view.
- getIcon() and getActiveIcon(). Icons of size 32 by 32 pixels that represent the composite view in its inactive and active states, respectively. In most cases, the same icon can be used for both.
- getViewLayout(). Specifies the user interface components provided by the framework that you want for the composite view.
- createSubComponents(). This method is invoked by the framework to initialize the user interface specific components that the composite view might have. It is important to implement the user interface initialization in this method instead of the constructor because the framework does not initialize the user interface containers until the composite view is actually rendered on screen.
Apply the composite view to the composite application. Add a com.ibm.ercp.compositeframework.compositeView extension in the MANIFEST.MF editor.
- For the most part, it is up to the implementor to provide methods for obtaining new instances of composite views through this provider class implementation. If a composite view is to be loaded by the framework at application startup time, however, the getStaticallyAvailableViews() method should be implemented to return an array of composite view instances that are to be loaded.
- Ensure that there is a default constructor, as this is how the framework instantiates these provider subclasses.
- Implement getLabel() & getIdentifier(). The identifier should be a uniquely identifying string for this provider instance.
- The compositeView element contains an attribute called viewProvider that should point to the composite view provider subclass that you just created (for example, com.ibm.ercp.sample.composite.host.SampleClientsViewProvider).
- The nested compositeViewGroupRef element contains a single attribute named idRef, which should contain the ID of the composite view group defined in the compositeApp extension (for example, sample.composite.host.viewGroup1).
Parent topic: Creating a mobile composite application: XPD621